Hi Arduino Forumer,
I need help to program Arduino for sending variable TTL signals to three LED. Each LED is powered by a driver which is equipped with TTL port. Thanks.
Best regards,
Alex Asanov
"variable TTL signals"
That doesn't really make sense - TTL signals are either High or Low.
You can vary them in time, based on inputs received elsewhere, such as a button press.
For example, you might read 3 buttons, 10 times a second, and send a high or a low based on whether the button is pressed or not:
byte button2 = 2; // connect with button that closes to Gnd when pressed
byte led3 = 3; // connect pin to LED driver
byte button4 = 4; // connect with button that closes to Gnd when pressed
byte led5 = 5;// connect pin to LED driver
byte button6 = 6; // connect with button that closes to Gnd when pressed
byte led7 = 7;// connect pin to LED driver
unsigned long currentTime;
unsigned long previousTime;
unsigned long duration = 100; // 100mS
void setup(){
pinMode (button2, INPUT_PULLUP); // pin with internal pullup resistor, reads as High until button is pressed
pinMode (button4, INPUT_PULLUP);
pinMode (button6, INPUT_PULLUP);
pinMode (led3, OUTPUT); // output to LED driver
pinMode (led5, OUTPUT);
pinMode (led7, OUTPUT);
} // end setup
void loop(){
currentTime = millis(); // read the 'time'
if ( (currentTime - previousTime) >= duration){ // 100mS passed?
previousTime = previousTime + duration // save time for next pass thru loop
if (digitalRead(button2) == LOW){ // is button pressed?
digitalWrite (led3, HIGH);} // yes, turn on LED
else{
digitalWrite(led3, LOW);} //no, turn off LED
if (digitalRead(button4) == LOW){
digitalWrite (led5, HIGH);}
else{
digitalWrite(led5, LOW);}
if (digitalRead(button6) == LOW){
digitalWrite (led7, HIGH);}
else{
digitalWrite(led7, LOW);}
} // end time check
// do other stuff while here while time passes
} // end loop