Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- DigitalReadSerial
- Reads a digital input on pin 2, prints the result to the serial monitor
- This example code is in the public domain.
- */
- // digital pin 2 has a pushbutton attached to it. Give it a name:
- int tiltA = 2;
- int tiltB = 3;
- int tiltC = 4;
- // the setup routine runs once when you press reset:
- void setup() {
- // initialize serial communication at 9600 bits per second:
- Serial.begin(9600);
- // make the pushbutton's pin an input:
- pinMode(tiltA, INPUT);
- pinMode(tiltB, INPUT);
- pinMode(tiltC, INPUT);
- }
- // the loop routine runs over and over again forever:
- void loop() {
- // read the input pin:
- int tiltAstate = digitalRead(tiltA);
- int tiltBstate = digitalRead(tiltB);
- int tiltCstate = digitalRead(tiltC);
- // print out the state of the button:
- Serial.println(tiltAstate);
- Serial.println(tiltBstate);
- Serial.println(tiltCstate);
- delay(1000); // delay in between reads for stability
- }
- //FIN
- void setup() {
- Serial.begin(10600);
- pinMode(13, OUTPUT);
- pinMode(12, OUTPUT);
- pinMode(11, OUTPUT);
- pinMode(10, OUTPUT);
- pinMode(9, OUTPUT);
- }
- void loop() {
- int pot = analogRead(A5);
- Serial.println(pot);
- delay(1);
- if (pot > 0 && pot < 205) {
- digitalWrite(12, LOW);
- digitalWrite(11, LOW);
- digitalWrite(10, LOW);
- digitalWrite(9, LOW);
- digitalWrite(13, HIGH);
- delay(2);
- }
- else if (pot > 205 && pot < 410) {
- digitalWrite(13, LOW);
- digitalWrite(11, LOW);
- digitalWrite(10, LOW);
- digitalWrite(9, LOW);
- digitalWrite(12, HIGH);
- delay(2);
- }
- else if (pot > 410 && pot < 615) {
- digitalWrite(13, LOW);
- digitalWrite(12, LOW);
- digitalWrite(10, LOW);
- digitalWrite(9, LOW);
- digitalWrite(11, HIGH);
- delay(2);
- }
- else if (pot > 615 && pot < 920) {
- digitalWrite(13, LOW);
- digitalWrite(12, LOW);
- digitalWrite(11, LOW);
- digitalWrite(9, LOW);
- digitalWrite(10, HIGH);
- delay(2);
- }
- else if (pot > 920 && pot <= 1024) {
- digitalWrite(13, LOW);
- digitalWrite(12, LOW);
- digitalWrite(11, LOW);
- digitalWrite(10, LOW);
- digitalWrite(9, HIGH);
- delay(2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement