Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int led1 = 2;
- int led2 = A1;
- int led3 = A2;
- int led4 = A3;
- int led5 = A4;
- int led6 = A5;
- int button1 = 0;
- int button2 = 0;
- int dh =1;
- const int transistorPin = 9; // connected to the base of the transistor
- void setup(void)
- {
- Serial.begin(9600);
- // set the transistor pin as output:
- pinMode(transistorPin, OUTPUT);
- pinMode(led1, OUTPUT);
- pinMode(led2, OUTPUT);
- pinMode(led3, OUTPUT);
- pinMode(led4, OUTPUT);
- pinMode(led5, OUTPUT);
- pinMode(led6, OUTPUT);
- pinMode(5, OUTPUT);
- pinMode(6, OUTPUT);
- pinMode(3, INPUT);
- pinMode(10, INPUT);
- }
- void loop(void){
- // read the potentiometer:
- int sensorValue = analogRead(A0);
- // map the sensor value to a range from 0 - 255:
- int outputValue = map(sensorValue, 0, 1023, 0, 255);
- // use that to control the transistor:
- analogWrite(transistorPin, outputValue);
- while (dh=1){
- // begin LEDs
- digitalWrite(led1, HIGH);
- delay(100);
- // read the potentiometer:
- int sensorValue = analogRead(A0);
- // map the sensor value to a range from 0 - 255:
- int outputValue = map(sensorValue, 0, 1023, 0, 255);
- // use that to control the transistor:
- analogWrite(transistorPin, outputValue);
- digitalWrite(led1, LOW);
- delay(100);
- digitalWrite(led2, HIGH);
- delay(100);
- digitalWrite(led2, LOW);
- delay(100);
- digitalWrite(led3, HIGH);
- delay(100);
- // read the potentiometer:
- // map the sensor value to a range from 0 - 255:
- // use that to control the transistor:
- analogWrite(transistorPin, outputValue);
- digitalWrite(led3, LOW);
- delay(100);
- digitalWrite(led4, HIGH);
- delay(100);
- digitalWrite(led4, LOW);
- delay(100);
- digitalWrite(led5, HIGH);
- delay(100);
- // read the potentiometer:
- // map the sensor value to a range from 0 - 255:
- // use that to control the transistor:
- analogWrite(transistorPin, outputValue);
- digitalWrite(led5, LOW);
- delay(100);
- digitalWrite(led6, HIGH);
- delay(100);
- digitalWrite(led6, LOW);
- delay(100);
- // backwards LEDs
- digitalWrite(3, HIGH);
- digitalWrite(10, HIGH);
- // read the potentiometer:
- // map the sensor value to a range from 0 - 255:
- // use that to control the transistor:
- analogWrite(transistorPin, outputValue);
- digitalWrite(led5, HIGH);
- delay(100);
- digitalWrite(led5, LOW);
- delay(100);
- // read the potentiometer:
- // map the sensor value to a range from 0 - 255:
- // use that to control the transistor:
- analogWrite(transistorPin, outputValue);
- digitalWrite(led4, HIGH);
- delay(100);
- digitalWrite(led4, LOW);
- delay(100);
- digitalWrite(led3, HIGH);
- delay(100);
- // read the potentiometer:
- // map the sensor value to a range from 0 - 255:
- // use that to control the transistor:
- analogWrite(transistorPin, outputValue);
- digitalWrite(led3, LOW);
- delay(100);
- digitalWrite(led2, HIGH);
- delay(100);
- digitalWrite(led2, LOW);
- delay(100);
- digitalWrite(led1, HIGH);
- digitalWrite(led1, LOW);
- // end LEDs
- }
- while (dh=1){
- button1 = digitalRead(3);
- button2 = digitalRead(10);
- if (button1 == LOW) {
- digitalWrite(5, HIGH);
- while(1);
- while(1) {
- }
- }
- if (button2 == LOW) {
- digitalWrite(6, HIGH);
- while(1);
- while(1) {
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement