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.