0% found this document useful (0 votes)
10 views

Arduino Asc 1

Uploaded by

infodz20232023
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Arduino Asc 1

Uploaded by

infodz20232023
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 4

#include <Stepper.

h>

#include <Servo.h>

Servo s;

#define btn3 5

#define btn2 6

#define btn1 7

#define led3 2

#define led2 12

#define led1 4

int i = 1;

Stepper small_stepper(100, 8, 10, 9, 11);

void closes (){

int j=s.read();

while(j>0){

j-=10;

s.write(j);

delay(300);

void setup() {

s.attach(3);

small_stepper.setSpeed(300);
Serial.begin(9600);

pinMode(btn3, INPUT);

pinMode(btn2, INPUT);

pinMode(btn1, INPUT);

pinMode(led3, OUTPUT);

pinMode(led2, OUTPUT);

pinMode(led1, OUTPUT);

digitalWrite(led3, LOW);

digitalWrite(led2, LOW);

digitalWrite(led1, LOW);

updateLEDs();

s.write(90);

void updateLEDs() {

digitalWrite(led1, i == 1 ? HIGH : LOW);

digitalWrite(led2, i == 2 ? HIGH : LOW);

digitalWrite(led3, i == 3 ? HIGH : LOW);

void moveElevator(int targetFloor) {


while (i != targetFloor) {

closes();

if (i < targetFloor) {

i++;

small_stepper.step(-2000);

} else if (i > targetFloor) {

i--;

small_stepper.step(2000);

Serial.print("On the way to Floor: ");

Serial.println(i);

updateLEDs();

if(targetFloor == i){

s.write(90);

delay(1000);

Serial.print("Arrived at Floor: ");

Serial.println(i);

updateLEDs();

}
void loop() {

Serial.print("Current Floor: ");

Serial.println(i);

delay(500);

if (digitalRead(btn3) == HIGH) {

moveElevator(3);

if (digitalRead(btn2) == HIGH) {

moveElevator(2);

if (digitalRead(btn1) == HIGH) {

moveElevator(1);

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy