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.

  • 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 Jan 22 '17 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 – raj Jan 22 '17 at 14:33
  • Edit your question and include the Arduino and Pi code you are using. – joan Jan 22 '17 at 14:57
  • added the scripts – raj Jan 26 '17 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 Jan 26 '17 at 9:12
-1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.