Alternating LED's With Adjustable Frequency
by elijs2008 in Circuits > Arduino
43 Views, 0 Favorites, 0 Comments
Alternating LED's With Adjustable Frequency
Made for Mech 1 Mr. Sweets Class
Code comes from Arduino Example Library
Main circuit comes from sparksfun
Supplies
Coding the Arduino
//Coded in C++
int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// turn the ledPin on
digitalWrite(ledPin, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
}
Wiring the Arduino
1) Connect the 5v pin to the positive lead on the breadboard and the ground pin to the negative lead
2) Place the potentiometer into the breadboard
3) The center pin of the potentiometer should be connected to any of the analog in pins (A 0-5), the left pin needs to be connected to negative and the right pin needs to be connected to positive
4) Place one of your LED's in the breadboard, wire the positive to pin 7 and place a resistor to ground
Wiring the NOT Gate
Wiring the PNP transistor
1) Place the PNP resistor in the bread board
2) Connect the Emitter pin to ground (The pinout from left to right, looking at the flat side is, Emitter Base Collector)
3) Connect the Collector to positive using a 100 ohm resistor
4) Connect the Collector to the LED positive lead
Combing the NOT Gate With the Flashing LED
1) Connect the arduino 7 pin to the base pin of the LED