Go Down

Topic: Connecting Arduino to PIC (Read 3 times) previous topic - next topic

siyete

Dec 24, 2012, 07:08 am Last Edit: Dec 24, 2012, 07:15 am by siyete Reason: 1
hi im doing this project FYI: im a beginner at programming..
i want to use the digital output of arduino and connect it to a pic16f877a pin..

so arduino(output) to pic16f877a(input)

i tried connecting it to my pic and it doesnt do anything..
i tried connecting a resistor and led to the connecting wires so that i will know if the connections are good..
and the led lights up, so arduino is sending a signal but the pic doesnt do anything..
what am i doing wrong?..

Osgeld

is the pic expecting input where your hooking up to? its a software driven device like the arduino

siyete

#2
Dec 24, 2012, 09:18 am Last Edit: Dec 24, 2012, 09:20 am by siyete Reason: 1
yes i configured all PORTA to input, here is part of my code for the pic:

Code: [Select]

ALL_DIGITAL = True
PORTB_PULLUPS = On

TRISA  = %111111
TRISB  = %00000000
TRISC  = %00000000
TRISD  = %00000000
TRISE  = %111

----------Arduino Controls----------
arduino:

If PORTA.2 = 1  And PORTA.3 = 1 Then
GoTo Forward_Slow
   
ElseIf PORTA.2 = 0  And PORTA.3 = 1 Then
GoTo Left_Slow
 
ElseIf PORTA.2 = 1  And PORTA.3 = 0 Then
GoTo Right_Slow

Else
   If PORTE.0 = 1 And PORTE.1 = 0 Then
   GoTo Grab_Ball
   
   ElseIf PORTE.0 = 0 And PORTE.1 = 1 Then
   GoTo Back_Slow
   
   Else
   GoTo Rotate_Right
   EndIf
EndIf
   
GoTo main

'----------Drive Controls----------
Forward_Slow:
High PORTD.0
Low  PORTD.1
High PORTD.2
Low  PORTD.3
Clear PORTD
GoTo main
     
Right_Slow:
High PORTD.1
High PORTD.2
Clear PORTD
GoTo main

Left_Slow:
High PORTD.0
High PORTD.3
Clear PORTD
GoTo main

Back_Slow:
Low  PORTD.0
High PORTD.1
Low  PORTD.2
High PORTD.3
Clear PORTD
GoTo main

Rotate_Right:
Low  PORTD.0
High PORTD.1
High PORTD.2
Low  PORTD.3
DelayMS 500
Clear PORTD
GoTo main


the led is lighting up, meaning the wiring is good right?.. and i believe the program is also good..
because when i switch the port meant for arduino and replace it with an infrared proximity sensor it does what it is supposed to do..
the proximity sensor also gives high and low signal, same as arduino but why when i plug arduino on the pic it does nothing..

mauried

Does the 16f887 have some kind of program in it ?

siyete

yes the pic16f877a is programmed to receive input
and the arduino is programmed to produce output..
both use digital signal..

Go Up