Skip to content

Instantly share code, notes, and snippets.

@L1fescape
Created February 25, 2013 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save L1fescape/5026942 to your computer and use it in GitHub Desktop.
Save L1fescape/5026942 to your computer and use it in GitHub Desktop.
Code from Arduino Demultiplexer and Potentiometer video http://youtu.be/tRjOoweOEaU
int sensorPin = A0;
int delayAmt = 0;
int led = 13; //just a led
void setup(){
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(led, OUTPUT);
digitalWrite(led, HIGH);
Serial.begin(9600);
}
void loop () {
delayAmt = analogRead(sensorPin);
digitalWrite(2, 0);
digitalWrite(3, 1);
digitalWrite(4, 1);
delay(delayAmt);
delayAmt = analogRead(sensorPin);
digitalWrite(2, 0);
digitalWrite(3, 0);
digitalWrite(4, 0);
delay(delayAmt);
delayAmt = analogRead(sensorPin);
digitalWrite(2, 0);
digitalWrite(3, 0);
digitalWrite(4, 1);
delay(delayAmt);
delayAmt = analogRead(sensorPin);
digitalWrite(2, 0);
digitalWrite(3, 1);
digitalWrite(4, 0);
delay(delayAmt);
delayAmt = analogRead(sensorPin);
digitalWrite(2, 1);
digitalWrite(3, 0);
digitalWrite(4, 1);
delay(delayAmt);
delayAmt = analogRead(sensorPin);
digitalWrite(2, 1);
digitalWrite(3, 1);
digitalWrite(4, 1);
delay(delayAmt);
delayAmt = analogRead(sensorPin);
digitalWrite(2, 1);
digitalWrite(3, 1);
digitalWrite(4, 0);
delay(delayAmt);
delayAmt = analogRead(sensorPin);
digitalWrite(2, 1);
digitalWrite(3, 0);
digitalWrite(4, 0);
delay(delayAmt);
delayAmt = analogRead(sensorPin);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment