Arduino Traffic Light Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 เม.ย. 2024
  • The Arduino traffic light is a fun little project that you can build in under an hour. Here's how to build your own using an Arduino, and how to change the circuit for an advanced variation.
    Complete code, wiring diagrams and written version of this tutorial can be found at: www.makeuseof.com/tag/arduino...
    We're using the Elegoo R3 Start Kit: amzn.to/2XZuq88
  • วิทยาศาสตร์และเทคโนโลยี

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

  • @user-ud3tu4yc5c
    @user-ud3tu4yc5c 7 หลายเดือนก่อน +2

    thanks man you really are a life saver I am going to have an exam in my embedded class at 8:30 and watch this video at 7:00 I've got a lot from this. Now my exam will be well done!

  • @hadireg
    @hadireg 3 ปีที่แล้ว +1

    nice video. for the dual traffic light as done so far, a simple wiring G1 with R2 ; O1 with O2 ; R1 with G2. the ports can still handle the current I guess.

    • @MakeUseOf
      @MakeUseOf  3 ปีที่แล้ว

      Nice. Yeh, you can easily drive quite a few LEDs from a basic Arduino. Check out our ancient LED cube project: th-cam.com/video/tqWAC4hu7nk/w-d-xo.html

  • @davidd2661
    @davidd2661 3 ปีที่แล้ว +5

    i made it myself and it worked :)

  • @wag-on
    @wag-on 3 ปีที่แล้ว +9

    I remember doing this in primary school in 1985 on a C64 computer with some external device attached.I had to add up the binary values to have the lights switched on/off. I had it how you've got with 2 lights immediately swapping but the teacher got me to modify it so both lights were red before either set proceeded to green. Loved it - just wish I knew what that gadget was called?

    • @wannarockful
      @wannarockful 2 ปีที่แล้ว +1

      a microcontroller SDK

    • @shmurga
      @shmurga ปีที่แล้ว +1

      I’m sorry but you didn’t #ratio

    • @AKGaming-sr5qm
      @AKGaming-sr5qm 7 หลายเดือนก่อน

      Where u belong to means which country 😅

  • @AKGaming-sr5qm
    @AKGaming-sr5qm 7 หลายเดือนก่อน

    Very good ur good teacher bhudau 😂

  • @official_prxalloteyezhpdsi6009
    @official_prxalloteyezhpdsi6009 2 ปีที่แล้ว

    Thank you very much

  • @stephanfouche7374
    @stephanfouche7374 4 ปีที่แล้ว

    Can you pls do a fading light video

  • @pranabdeka209
    @pranabdeka209 3 ปีที่แล้ว

    Can I buy this kit online

  • @guruprasadkulkarni635
    @guruprasadkulkarni635 ปีที่แล้ว

    how can i add another 4 led to make traffic signal?

  • @darwinbelliard9664
    @darwinbelliard9664 3 ปีที่แล้ว

    does the code work on Matlab?

  • @habibsaliu6208
    @habibsaliu6208 3 ปีที่แล้ว

    my red and green come up at d same time how do i fix dis

  • @anemcnes193
    @anemcnes193 2 ปีที่แล้ว

    i remember doing this back in year 7

  • @MelinyanisoMapi
    @MelinyanisoMapi 3 ปีที่แล้ว

    Question, can the same logic work for an station indicator e.g Indicator light change to Red, green or yellow based on a on a DB field, my db is MSSQL, i want to do this project and looking for some inspirations

  • @airchannel2011
    @airchannel2011 7 หลายเดือนก่อน

    red and yellow not turning on on sametime

  • @ahmedkahie6009
    @ahmedkahie6009 3 ปีที่แล้ว

    Nice Video, but do you know how to make a junction with four traffic lights. I have suceed with two lights but i don't know how to make with four.

    • @MakeUseOf
      @MakeUseOf  3 ปีที่แล้ว +1

      Wouldn't that just be another set of each lights? Just a case of adding more LEDs to the same pins, you wouldn't need to adjust the coding, unless you wanted specific code for turning left/right stages?

    • @ahmedkahie6009
      @ahmedkahie6009 3 ปีที่แล้ว

      Thank you for the reply. Two are in a row and two in the bottom. I need to know how to make right left stages

    • @ahmedkahie6009
      @ahmedkahie6009 3 ปีที่แล้ว

      @MakeUseOf The code only works for two traffic Lights

  • @christiancasasos2771
    @christiancasasos2771 2 ปีที่แล้ว

    yellow and red turn on before the green turns on

  • @reinsaris
    @reinsaris 3 ปีที่แล้ว +1

    8:10 when i compile changeLights()" on line 22 gives an error 'expected ')' before ';' token'. does anyone knows how to fix this?

    • @MakeUseOf
      @MakeUseOf  3 ปีที่แล้ว +1

      Have you ended all lines with ; ?

    • @reinsaris
      @reinsaris 3 ปีที่แล้ว +1

      MakeUseOf I found out what i was doing wrong, after an earlier ‘{‘ I didn’t close it. Thank you for your reply!

  • @louisferreira1012
    @louisferreira1012 4 ปีที่แล้ว

    how does the arduino board know to start with only the green pin at high and then all other pins low for 15s???

  • @funasfriend150
    @funasfriend150 3 ปีที่แล้ว +1

    Could we extend the time duration of light

  • @onnio7998
    @onnio7998 2 ปีที่แล้ว

    You can make a counter feom 1 to 4, one up every 5 seconds for example. Then say that green is on when counter is 1, yellow is on when counter is 2 or 4 and red is on when counter is 3.

    • @MakeUseOf
      @MakeUseOf  2 ปีที่แล้ว

      That's a good approach!

  • @nickhale2900
    @nickhale2900 4 ปีที่แล้ว

    I would love to create something along those line for a model railway signal triggered by an IR obstacle sensor but I have not got a clue how to modify the code.

    • @MakeUseOf
      @MakeUseOf  4 ปีที่แล้ว

      This was my first project, having never touched an Arduino before. It's easy once you dive in!

  • @luomnguyenvan1479
    @luomnguyenvan1479 4 ปีที่แล้ว +1

    Code ??

  • @IOTmug
    @IOTmug 3 ปีที่แล้ว +1

    here I am it is me: ) Thanks for creating video about me :)

  • @dane7205
    @dane7205 3 ปีที่แล้ว

    I followed your video & your written version. The Traffic Lights worked, until I installed the button & modified the sketch. Getting an Error Message
    "Error compiling for board Arduino Nano". I'm using a Arduino Nano. Any thoughts? Please

  • @alifsaifuddin6192
    @alifsaifuddin6192 3 ปีที่แล้ว

    why use 6 resistor 220 when u just use 4 resistor in the video

  • @monstrousdemon4565
    @monstrousdemon4565 4 ปีที่แล้ว

    👍🏼

  • @josevaldivia9908
    @josevaldivia9908 4 ปีที่แล้ว

    Could you connect this to an actual set of light bulbs and have it do the same thing?

    • @MakeUseOf
      @MakeUseOf  4 ปีที่แล้ว +3

      Sure, but you'd need a relay if the lightbulbs are running on AC power, and I wouldn't suggest playing with AC power if this is your first Arduino project!

  • @galileib08icasiamcyruzstev45
    @galileib08icasiamcyruzstev45 3 ปีที่แล้ว

    You said 10 kohm resistor at 6:07 but the color band in the picture diagram show only 1 kohm resistor (brown,black,red)... 10 k ohm resistor should be brown, black, yellow

  • @enzo991_
    @enzo991_ 5 ปีที่แล้ว

    I know this is probably unrelated, but I've been trying to find a tutorial for a Verilog code that does this exact same thing, simulate a single traffic light using the LEDs on the FPGA board. Do you have any idea where I can find such a tutorial ?

    • @thad4342
      @thad4342 4 ปีที่แล้ว

      AllInTheManual I’m looking for that as well

  • @user-hw6iy4wu9j
    @user-hw6iy4wu9j ปีที่แล้ว

    I manage to write the code for the two traffic lights and a single button to control them, took me a while to sort the code out though...

  • @JerryKillian
    @JerryKillian 4 ปีที่แล้ว

    I have the Elegoo Uno R3 starter it as well. However, I had some issues with the code. For some strange reason, the lights were not operating as described in the code. I ended up having to put the OPPOSITE values for on and off.
    example:
    void changeLights(){
    // green off, yellow on for 3 seconds
    digitalWrite(yellow, LOW);
    digitalWrite(red, HIGH);
    digitalWrite(green, HIGH);
    delay(3000);
    If I did not enter the values of each pin, the LED would stay on if I wanted it off. I had hand-typed the code as you have it on your website, copied/pasted as well. but only got the desired results when I changed the values as given.Also, this always starts with yellow every time. I know, right? Strange, but true.

  • @AnthonyGoodley
    @AnthonyGoodley 2 ปีที่แล้ว

    I just bought a real traffic light. As in a full size real stoplight. Could code like this be used to control the lights so that it doea more than just display all the lights on all the time?

    • @MakeUseOf
      @MakeUseOf  2 ปีที่แล้ว

      In theory, yes, but it depends on how your traffic light is wired up. If it designed to show them all at once, it could be that there's only a single light source in there, with three different colored lenses. Alternatively, you could wire up your own LED light sources behind each section?

    • @AnthonyGoodley
      @AnthonyGoodley 2 ปีที่แล้ว

      @@MakeUseOf I'll be picking it up in a few hours. I'll dig in and explore it more soon. I'm guessing it has 3 different light sources and that someone did a bit of rewiring so that all 3 lights stay on constantly.

  • @shehnazmasarweh1526
    @shehnazmasarweh1526 ปีที่แล้ว

    I use the switch button for it
    And for code the “if” statement method

  • @irinaktersnigdha5083
    @irinaktersnigdha5083 ปีที่แล้ว

    Please provide the source code

    • @MakeUseOf
      @MakeUseOf  ปีที่แล้ว

      Apologies, our theme broke the source code. Please check the link in the description in a few days, it should be working again soon.

  • @monstrousdemon4565
    @monstrousdemon4565 4 ปีที่แล้ว

    👍🏼😡

  • @dlegendarypro
    @dlegendarypro 3 ปีที่แล้ว

    lmao copyright