0

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.

asked Jan 22, 2017 at 5:25
6
  • 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? Commented 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 work Commented Jan 22, 2017 at 14:33
  • Edit your question and include the Arduino and Pi code you are using. Commented Jan 22, 2017 at 14:57
  • added the scripts Commented 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. Commented Jan 26, 2017 at 9:12

1 Answer 1

-1

The problem lied somewhere in connection only. Changing the pinTTL=6 solved the problem.

answered Jan 27, 2017 at 3:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.