I am trying to send TTL pulse at 1second interval to Raspberry pi? Can someone suggest me a good way to do it using GPIO or any other way possible.
Arduino Code:
void setup() {
pinMode(12, OUTPUT);
}
void loop() {
digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(12, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Raspberry Pi Code:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
pinTTL = 4
GPIO.setup(pinTTL, GPIO.IN)
start_time = time.time()
t_end = start_time + 60
while time.time()<t_end:
inputState = GPIO.input(pinTTL)
if inputState == True:
print 'HIGH', time.time() - start_time
else:
print 'LOW', time.time() - start_time
GPIO.cleanup()
Another thing is I have checked using multimeter, the voltage on Pi output pin does change at 1second interval.
-
What have you tried? Where is your Arduino code? Where is your Pi code? How have you dropped the Arduino 5V GPIO to a Pi safe 3V3?joan– joan2017年01月22日 10:45:05 +00:00Commented Jan 22, 2017 at 10:45
-
I have dropped the 5v arduino output to 3.3v for making it safe for Pi. I just used a normal arduino code for setting the pin output high and low at 1second interval to see if this works and whether the raspberry pi input pin detects that but I coulnd't get it workraj– raj2017年01月22日 14:33:06 +00:00Commented Jan 22, 2017 at 14:33
-
Edit your question and include the Arduino and Pi code you are using.joan– joan2017年01月22日 14:57:33 +00:00Commented Jan 22, 2017 at 14:57
-
added the scriptsraj– raj2017年01月26日 06:02:45 +00:00Commented Jan 26, 2017 at 6:02
-
Presumably you haven't connected the correct Arduino pin to the correct Pi pin. Please add a photo. abyz.co.uk/rpi/pigpio/index.html#Type_3 shows the position of GPIO4 on pin 7.joan– joan2017年01月26日 09:12:00 +00:00Commented Jan 26, 2017 at 9:12
1 Answer 1
The problem lied somewhere in connection only. Changing the pinTTL=6 solved the problem.