Before I start, Id just like to clarify that the only programming experience I have had is with VB. As such, I found picbasic's programming protocol rather easy. However, I have had no luck in getting my microcontroller to function.
My plan is :
1) Whenever the user presses a button on the controller, a signal is sent to any of the inputs which in turn causes an output to pulse.
2) The pulses for movement differ and are transmitted to the car using an infrared transmitter.
3) When they reach the car, these pulses are decoded and the proper output becomes active high and the car runs in the proper direction.
Im sorry if Im asking a bit too much, but I really need this to get to work as my project is due by friday.
thx
'************************************************* *****************************
'This is the code for the transmitter in the remote
Device = 16F84A
XTAL = 4 'Dont know clock frequency
Input PortA
Output PortB
If PortA.2 = 1 Then 'RA2 is input, Forward
PulsOut PortB.7 , 50 'RB7 = output, Pulse = 0.5 ms long
ElseIf PortA.3 = 1 Then 'RA3 is input, Reverse
PulsOut PortB.6, 100 'RB6 = output, Pulse = 100 ms long
ElseIf PortA.1 = 1 Then 'RA1 is input, Right
PulsOut PortB.5, 150 'RB5 = output, Pulse = 150 ms long
ElseIf PortA.0 = 1 Then 'RA0 is input, Left
PulsOut PortB.4, 200 'RB4 = output, Pulse = 200 ms long
End If
'************************************************* *****************************
'************************************************* *****************************
'This is the code for the reciever in the car
Device = 16F84A
XTAL = 4
Input PortA
Output PortB
Dim Move as Byte
Loop:
Move = PulsIn PortA.2, 1 'RA2 = input
If Move = 200 Then 'Left
PortB.7 = 1 'RB7 = output
ElseIf Move = 150 Then 'Right
PortB.6 = 1 'RB6 = output
ElseIf Move = 100 Then 'Reverse
PortB.5 = 1 'RB5 = output
ElseIf Move = 50 Then 'Forward
PortB.4 = 1 'RB4 = output
End If
GoTo Loop
'************************************************* *****************************
Bookmarks