Go Down

Topic: 8+ two LED functions off one pin (Read 2269 times) previous topic - next topic

steinie44

May 28, 2014, 08:51 pm Last Edit: Jun 18, 2014, 01:52 pm by steinie44 Reason: 1
Hi everyone. Check out my build of a 2 LED Module that has 8+ functions off only one Arduino pin.
Watch my YouTube video at: http://www.youtube.com/watch?v=8uZndVTIc24&feature=share&list=UU0_hiu0q4bHnGHtiJcG4sDw
Code: [Select]

/* Module_2_LEDs 17 May 2014 JDS  :)
To make this module:
1) 1" X 1.5" perf board
1) male 3 pin header
2) female 2 pin headers
1) 220 Ohm reststor
1) 74LS04 IC or any inverter IC like 74LS02 etc.
2) LEDs

Wireing the module:
3 pin male header pins are:
Signal, 5 Volts, Ground.
Connect the Signal pin to a inverter input and one pin
of each 2 pin female headers.
Connect the inverter output to the other side of the
two female 2 pin headers.
Connect the 5 Volt male header to the IC pin 14 of 74LS04
Connect the Ground male header to the IC pin 7 of 74LS04.
Plug 2 LEDs into the 2 female 2 pin headers, one
cathode, and on Anode, to the signal side.
That's it!
Then connect the Signal to Arduino pin 3 'in this example'.
Connect 5 Volt pin to Arduino 5 Volts
Connect Ground pin to Arduino Ground.
Then load and run this program.
*/
int i;
int j;
int SignalPin = 3;
void setup() {
 pinMode(SignalPin,OUTPUT);
 Serial.begin(9600);
}
void loop() {
 Serial.println();
 Serial.println("JDS LED Module");
 Serial.println("by: Jim Steinbrecher");
 Serial.println("All off one Arduino pin.");
 Serial.println();

 digitalWrite(SignalPin,HIGH);
 Serial.println("One LED on");
 delay(5000);

 digitalWrite(SignalPin,LOW);
 Serial.println("Other LED on");
 delay(5000);

 Serial.println("One LED Flashing");
 digitalWrite(SignalPin,HIGH);
 for (i = 1; i < 25; i++)
 {
 pinMode(SignalPin, INPUT);
 delay(100);
 pinMode(SignalPin, OUTPUT);
 digitalWrite(SignalPin,HIGH);
 delay(100);
 }

 Serial.println("Other LED Flashing");
 digitalWrite(SignalPin, LOW);
 for (i = 1; i < 25; i++)
 {
 pinMode(SignalPin, INPUT);
 delay(100);
 pinMode(SignalPin, OUTPUT);
 digitalWrite(SignalPin, LOW);
 delay(100);
 }


 Serial.println("Flashing LEDs");
 for (i = 1; i < 25; i++)
 {
 digitalWrite(SignalPin,HIGH);
 delay(100);
 digitalWrite(SignalPin,LOW);
 delay(100);
 }

 Serial.println("Both LEDs on");
 for (i = 1; i < 2500; i++)
 {
 digitalWrite(SignalPin,HIGH);
 delay(1);
 digitalWrite(SignalPin,LOW);
 delay(1);
 }

 pinMode(SignalPin,INPUT);
 Serial.println("Both LEDs off");
 delay(5000);
 pinMode(SignalPin,OUTPUT);

 Serial.println("Flashing LEDs with PWM");
 for (i = 1; i < 10; i++)
 {
 for (j = 1; j < 255; j++)
 {
 analogWrite(SignalPin, j);
 delay(2);
 }
 for(j = 255; j > 0; j--)
 {
 analogWrite(SignalPin, j);
 delay(2);
 }
 }
}


Go Up