Posts

Showing posts from October, 2020

5 channel chaser light

Image
int m1a = 9; int m2a = 10; int m1b = 11; int m2b = 12; int m1c = 13; char val; void setup () { pinMode(m1a,OUTPUT); pinMode(m2a,OUTPUT); pinMode(m1b,OUTPUT); pinMode(m2b,OUTPUT); pinMode(m1c,OUTPUT); } void loop () { digitalWrite(m1a,HIGH); delay(100); digitalWrite(m1a,LOW); digitalWrite(m2a,HIGH); delay(100); digitalWrite(m2a,LOW); digitalWrite(m1b,HIGH); delay(100); digitalWrite(m1b,LOW); digitalWrite(m2b,HIGH); delay(100); digitalWrite(m2b,LOW); digitalWrite(m1c,HIGH); delay(100); digitalWrite(m1c,LOW); }

Ultrasonic sensor and led programming

Image
code- #define trigPin 11 #define echoPin 12 #define led 13 void setup() { Serial.begin (9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(led, OUTPUT); } void loop() { long duration, distance; digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = (duration/2) / 29.1; if (distance < 10) { digitalWrite(led,HIGH); } else { digitalWrite(led,LOW); } Serial.print(distance); Serial.println(" cm"); delay(500); }

Forward backward swith diy

Image