Pametne osvijetljene stube
Zajednica tehničke kulture Valpovo-BelišćeModel osvijetljenoga stubišta koje uključuje rasvjetu na stubištu u odnosu na mjesto gdje osoba trenutno stoji. Osvijetljena je stuba na kojoj se osoba trenutno nalazi te jedna stuba ispred i jedna stuba iza trenutne stube. Koristimo Arduino MKR1000, 10 LED-ica te ultrazvučni senzor udaljenosti. Mobilna aplikacija prikazuje udaljenost predmeta od senzora udaljenosti.
Izrada projekta
Projekt je modularan, a lemljene su jedino svjetleće diode i otpornici i to na žice za prototipiranje kako bi se mogle isključiti.
Mobilna aplikacija
Shema projekta
Arduino program
#define BLYNK_PRINT /* int led1 = 1; int led2 = 2; int led3 = 3; int led4 = 4; int led5 = 5; int led6 = 6; int led7 = 7; int led8 = 8; int led9 = 9; int led10 = 10; #define BLYNK_PRINT SerialUSB #include #include #include const int trigPin = 12; const int echoPin = 11; long duration; int distance; char auth[] = "8e70ced57eeb4f908174ad7d4b927d44"; //Ključ za blynk aplikaciju char ssid[] = "KUDELJNJAK"; char pass[] = "12344321"; BlynkTimer timer; void setup() { Blynk.begin(auth, ssid, pass); timer.setInterval(500L, sendSensor); pinMode(led1,OUTPUT); pinMode(led2,OUTPUT); pinMode(led3,OUTPUT); pinMode(led4,OUTPUT); pinMode(led5,OUTPUT); pinMode(led6,OUTPUT); pinMode(led7,OUTPUT); pinMode(led8,OUTPUT); pinMode(led9,OUTPUT); pinMode(led10,OUTPUT); pinMode(trigPin, OUTPUT); // Postavljane trigger pina kao izlaz pinMode(echoPin, INPUT); // Postavljanje echo pina kao ulaz Serial.begin(9600); // Pocetak serijske komunikacije } void sendSensor() //Funkcija za čitanje senzora { digitalWrite(trigPin, LOW); //zapocinjemo citanje udaljenosti delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance= duration*0.034/2; Blynk.virtualWrite(V5, distance); } void loop() { Blynk.run(); //Pocetak blynk timer.run(); digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance= duration*0.034/2; //Racunamo udaljenost iz brzine zvuka i dijelimo s dva jer je zvuk dva puta presao izmjerenu udaljenost Serial.print("Distance: "); Serial.println(distance); if (distance<=3){ //petlja za ukljucivanje dioda digitalWrite(led1,HIGH); digitalWrite(led2,LOW); digitalWrite(led3,LOW); digitalWrite(led4,LOW); digitalWrite(led5,LOW); digitalWrite(led6,LOW); digitalWrite(led7,LOW); digitalWrite(led8,LOW); digitalWrite(led9,LOW); digitalWrite(led10,LOW); } if(distance>3 && distance<=6){ digitalWrite(led1,HIGH); digitalWrite(led2,HIGH); digitalWrite(led3,LOW); digitalWrite(led4,LOW); digitalWrite(led5,LOW); digitalWrite(led6,LOW); digitalWrite(led7,LOW); digitalWrite(led8,LOW); digitalWrite(led9,LOW); digitalWrite(led10,LOW);} if(distance>6 && distance<=9){ digitalWrite(led1,HIGH); digitalWrite(led2,HIGH); digitalWrite(led3,HIGH); digitalWrite(led4,LOW); digitalWrite(led5,LOW); digitalWrite(led6,LOW); digitalWrite(led7,LOW); digitalWrite(led8,LOW); digitalWrite(led9,LOW); digitalWrite(led10,LOW);} if(distance>9 && distance<=12){ digitalWrite(led1,LOW); digitalWrite(led2,HIGH); digitalWrite(led3,HIGH); digitalWrite(led4,HIGH); digitalWrite(led5,LOW); digitalWrite(led6,LOW); digitalWrite(led7,LOW); digitalWrite(led8,LOW); digitalWrite(led9,LOW); digitalWrite(led10,LOW);} if(distance>12 && distance<=15){ digitalWrite(led1,LOW); digitalWrite(led2,LOW); digitalWrite(led3,HIGH); digitalWrite(led4,HIGH); digitalWrite(led5,HIGH); digitalWrite(led6,LOW); digitalWrite(led7,LOW); digitalWrite(led8,LOW); digitalWrite(led9,LOW); digitalWrite(led10,LOW);} if(distance>15 && distance<=18){ digitalWrite(led1,LOW); digitalWrite(led2,LOW); digitalWrite(led3,LOW); digitalWrite(led4,HIGH); digitalWrite(led5,HIGH); digitalWrite(led6,HIGH); digitalWrite(led7,LOW); digitalWrite(led8,LOW); digitalWrite(led9,LOW); digitalWrite(led10,LOW);} if(distance>18 && distance<=21){ digitalWrite(led1,LOW); digitalWrite(led2,LOW); digitalWrite(led3,LOW); digitalWrite(led4,LOW); digitalWrite(led5,HIGH); digitalWrite(led6,HIGH); digitalWrite(led7,HIGH); digitalWrite(led8,LOW); digitalWrite(led9,LOW); digitalWrite(led10,LOW);} if(distance>21 && distance<=24){ digitalWrite(led1,LOW); digitalWrite(led2,LOW); digitalWrite(led3,LOW); digitalWrite(led4,LOW); digitalWrite(led5,LOW); digitalWrite(led6,HIGH); digitalWrite(led7,HIGH); digitalWrite(led8,HIGH); digitalWrite(led9,LOW); digitalWrite(led10,LOW);} if(distance>24 && distance<=27){ digitalWrite(led1,LOW); digitalWrite(led2,LOW); digitalWrite(led3,LOW); digitalWrite(led4,LOW); digitalWrite(led5,LOW); digitalWrite(led6,LOW); digitalWrite(led7,HIGH); digitalWrite(led8,HIGH); digitalWrite(led9,HIGH); digitalWrite(led10,LOW);} if(distance>27 && distance<=30){ digitalWrite(led1,LOW); digitalWrite(led2,LOW); digitalWrite(led3,LOW); digitalWrite(led4,LOW); digitalWrite(led5,LOW); digitalWrite(led6,LOW); digitalWrite(led7,LOW); digitalWrite(led8,HIGH); digitalWrite(led9,HIGH); digitalWrite(led10,HIGH);} if(distance>50 && distance<=55){ digitalWrite(led1,LOW); digitalWrite(led2,LOW); digitalWrite(led3,LOW); digitalWrite(led4,LOW); digitalWrite(led5,LOW); digitalWrite(led6,LOW); digitalWrite(led7,LOW); digitalWrite(led8,LOW); digitalWrite(led9,HIGH); digitalWrite(led10,HIGH);} if(distance>55 && distance<=60){ digitalWrite(led1,LOW); digitalWrite(led2,LOW); digitalWrite(led3,LOW); digitalWrite(led4,LOW); digitalWrite(led5,LOW); digitalWrite(led6,LOW); digitalWrite(led7,LOW); digitalWrite(led8,LOW); digitalWrite(led9,LOW); digitalWrite(led10,HIGH);} if(distance>60){ digitalWrite(led1,LOW); digitalWrite(led2,LOW); digitalWrite(led3,LOW); digitalWrite(led4,LOW); digitalWrite(led5,LOW); digitalWrite(led6,LOW); digitalWrite(led7,LOW); digitalWrite(led8,LOW); digitalWrite(led9,LOW); digitalWrite(led10,LOW);} }
Arduino program ovoga projekta možete preuzeti ovdje.
Autori
Projekt su izradili Nikola Kokić i Fran Koprivnjak uz mentorstvo Tomislava Kudeljnjaka iz Zajednica tehničke kulture Valpovo-Belišće.
Projekt je prijavljen na temu: Internet of Things: Pametna rasvjeta.