Arduino Traffic Light - Autodesk Tinkercad

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ต.ค. 2018
  • IMTx: DMx102
    Arduino Programming, from novice to ninja
    Lab 1 (auto-graded)
    1. All the pins have to be set as OUTPUT at the beginning of the sketch
    2. The green LED (on pin 4) is switched on for 3 seconds (green LED will be the first to light up) then it is switched off
    3. When the green LED is switched off, orange LED is switched on for 1 second then it is switched off again
    4. When the orange LED is switched off, red LED is switched on for 3 seconds then it is switched off again
    5. These instructions must run again and again in the loop()!
    Here is the source code:
    "
    void setup()
    {
    pinMode(4, OUTPUT);
    pinMode(3, OUTPUT);
    pinMode(2, OUTPUT);
    }
    void loop()
    {
    digitalWrite(4, HIGH); // For green LED
    delay(3000); // Wait for 3 second
    digitalWrite(4, LOW);
    digitalWrite(3, HIGH); // For orange LED
    delay(1000); // Wait for 1 second
    digitalWrite(3, LOW);

    digitalWrite(2, HIGH); // For the red LED
    delay(3000); // Wait for 3 second
    digitalWrite(2, LOW);
    }
    "
    More details: courses.edx.org/courses/cours...
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น •