I want to create some sort of multiplayer game system where multiple pics can communicate with each other using the inbuilt UART. I have been getting some excellent help once again from the team over at http://www.digital-diy.com
Here is my test circuit: Basically I have two 18f4685 PICs and they are connected by two wires RX and TX on the built in UART.
The image you are seeing is drawn by sending data serially from one pic to the other. So one has the face data stored within it, it then sends the data to the receiving pic which takes care of sending the data to the LED display.
I guess this is just the start - a sort of 'proof of concept' if you will. My ultimate goal is to have two handheld game devices where you can play games such as tetris or connect four or maybe even a game of chasey based around a mario bros game map. The two game devices would connect to each other wirelessly (using the UART) and they would continually send data between each other to let each other know what they are doing. for example if we are playing connect four and player one has just had their turn, we would need to display this data on both player 1's screen and also send that data for display on player 2's screen etc...
I look forward to where this project may be headed. it may be a slow process getting there due to time constraints but we will see!
and lastly, here is the test TX code:
Code: Select all
Device = 18F4685
Clock = 8
Config OSC = IRCIO67
// import library's
Include "usart.bas"
Const green_data(8) As Byte = (%11000011,%10111101,%01010110,%01111010,%01111010,%01010110,%10111101,%11000011)
Dim number As Byte
Dim x As Byte
// Start Of Program...
OSCCON = %01111111
TRISD = %00000000
TRISA = %00000000
number = %10101010
SetBaudrate(br115200)
DelayMS(160)
While true
For x = 0 To 7
USART.Write("start")
USART.WaitForStr("go")
USART.Write(green_data(x))
DelayMS(1)
Next
Wend
RX code:
Code: Select all
Device = 18F4685
Clock = 8
Config OSC = IRCIO67
Include "USART.bas"
Include "SUART.bas"
Include "utils.bas"
Dim green_data As Byte
Dim x As Byte
// Start Of Program...
OSCCON = %01111111
TRISD = %00000000
PORTD = %00000000
TRISA = %00000000
PORTA = %00000000
TRISB = %00000000
PORTB = %00000000
TRISE = %00000000
PORTE = %00000000
SetBaudrate(br115200)
DelayMS(150)
PORTA = %00000000
PORTE = %00000000
While true
For x = 0 To 7
USART.WaitForStr("start")
USART.Write("go")
USART.Read(green_data)
PORTB = green_data
If x < 6 Then
PORTA.bits(x) = 1
ElseIf x = 6 Then
PORTE.bits(0) = 1
ElseIf x = 7 Then
PORTE.bits(1) = 1
EndIf
DelayMS(1)
PORTA = 0
PORTE = 0
Next
Wend