Traffic light code (beginner level coding)

Hello all!
I'm a new member to the arduino community.
I received my duemilanove yesterday in the mail and she is indeed a beauty.

This morning I started familiarizing myself with coding and decided "why not make my own?".
After an hr or 2 (lost count) of trial and error, I finally came up with this short traffic light LED code.
Try it for yourself =) [code]// Traffic light code designed by Marquez Santos! (on facebook) // Connect green LED to pin 13 // Connect yellow LED to pin 12 // Connect red LED to pin 11 void setup() { // declare pin 11,12,13 to be outputs: pinMode(11, OUTPUT); pinMode(12, OUTPUT); pinMode(13, OUTPUT); } void loop(){{ digitalWrite(13, HIGH); // Turns LED on pin 13 on delay(2500); // LED on pin 13 remains on for 5 seconds digitalWrite(13, LOW); // Turns LED on pin 13 off delay(0);} digitalWrite(12, HIGH); // Turns LED on pin 12 on delay(2500); // LED on pin 12 remains on for 5 seconds digitalWrite(12, LOW); // Turns LED on pin 12 off delay(0); digitalWrite(11, HIGH); // Turns LED on pin 11 on delay(2500); // LED on pin 11 remains on for 5 seconds digitalWrite(11, LOW); // Turns LED on pin 11 off delay(0); }[/code] Double lane code below [code]// Traffic light code designed by Marquez Santos! (on facebook) // Connect green LED to pin 13 and 7 // Connect yellow LED to pin 12 and 6 // Connect red LED to pin 11 and 5 int var = 0; void setup() { // declare pins 11,12,13,5,6,7 to be outputs: pinMode(11, OUTPUT); pinMode(12, OUTPUT); pinMode(13, OUTPUT); pinMode(7, OUTPUT); pinMode(6, OUTPUT); pinMode(5, OUTPUT); } void loop(){{delay(1000); if (var == 0) digitalWrite(5, HIGH); delay(0); var = 1; if (var == 1) digitalWrite(13, HIGH); delay(0); var = 0; } { delay(7000); if (var == 0) digitalWrite(13, LOW); delay(0); var = 1; if (var == 1) digitalWrite(12, HIGH); delay(0); var = 2;} { delay(5000); if (var == 2) digitalWrite(11, HIGH); delay(0); var = 2; if (var == 2) digitalWrite(12, LOW); delay(0); var = 3; } { delay(3000); if (var == 3) digitalWrite(11, HIGH); delay(0); var = 4; if (var == 4) digitalWrite(5, HIGH); delay(0); var = 3; }{ delay(3000); if (var == 3) digitalWrite(11, HIGH); delay(0); var = 2; if (var == 2) digitalWrite(5, LOW); delay(0); var = 2; if (var == 2) digitalWrite(7, HIGH); delay(0); var = 4;} { delay(5000); if (var == 4) digitalWrite(11, HIGH); delay(0); var = 2; if (var == 2) digitalWrite(7, LOW); delay(0); var = 3; if (var == 3) digitalWrite(6, HIGH); delay(0); var = 2; } { delay(3000); if (var == 2) digitalWrite(6, LOW); delay(0); var = 3; if (var == 3) digitalWrite(5, HIGH); delay(0); var = 4; if (var == 4) digitalWrite(11, HIGH); delay(0); var = 3; } {delay(3000); if (var == 3) digitalWrite(5, HIGH); delay(0); var = 4; if (var == 4) digitalWrite(11, HIGH); delay(0); var = 3; } {delay(000); if (var == 3) digitalWrite(11, LOW); delay(0); var = 2; if (var == 2) digitalWrite (13, HIGH); delay(0); var = 3; } }[/code]

Interfacing RC-522 RFID

Hi, can anybody help me, how to use RC-522 RFID device, with ATmega? I have downloaded an example program yet, but it used "RFID.h" which is not included in the basic Arduino libraries. Can I use RFID without special library? If I can't, where can I obtain the appropriate library from? Thanks for the answers!

Pure Sine Wave Inverter Design

I am designing a pure sinewave inverter, 220V, 50 Hz.
Here is the complete design,
[img]http://i.imgur.com/QpX93md.png[/img]
without filter i simulate the whole circuit and tried to plot the current waveform by placing a current probe in RL Load (R = 5 Ohm, L = 16 mH).
I should be getting a sinusoidal current waveform but it is giving my arbitrary result. what might be the problem ?
I have followed this article for PWM generation using Atmega16.
Switching Frequency 16 Khz.
Fundamental Frequency 50 Hz.
http://tahmidmc.blogspot.com/2013/02...mode_2525.html
An external crystal is being used for 16 Mhz clock frequency.
here is the configuration i have done .
[img]http://i.imgur.com/JjK5UYJ.png[/img]

Here is the PWM waveform
[img]http://i.imgur.com/jPlB2it.png[/img]

[img]http://i.imgur.com/cXcdX7y.png[/img]



Instead of IR2110 i have used IR2112, as IR2110 is not available in Proteus. MOSFET Driver circuit is working fine, i have checked the voltage at gate and it is turning it ON/OFF.
MOSFETS are working good.

If i directly filter the PWM signal using RC filter i am getting a sinusoidal voltage waveform.

What might be the problem that i am not getting sinusoidal current waveform ????
If someone interested in debugging my circuit or just wants to run it in their Proteus please tell i will attach the design file.

Here is what i am getting when simulate the circuit
Current waveform
[img]http://i.imgur.com/XbKkVQz.png[/img]

Voltage Waveform
[img]http://i.imgur.com/rp0XPZp.png[/img]

Any help will be appreciated

I wish tahmid is here to help me out, he is the best guy when it comes to share knowledge and helping out.[img][/img]

Problem with Nrf24L01+ and arduino mega

I have two Arduino (a mega and nano) and two nRF24L01 + to communicate them.

The connection of the wires according to the library and using the SPI pins modeled on arduino.

NANO 328:
MISO -> 12
MOSI -> 11
SCK -> 13
CE -> 8
CSN -> 7
GND -> GND
VCC -> 3.3v

MEGA 2560:
MISO -> 50
MOSI -> 51
SCK -> 52
CE -> 8
CSN -> 7
GND -> GND
VCC -> 3.3v

Use the library "Mirf" found in the playground (http://www.arduino.cc/playground/InterfacingWithHardware/Nrf24L01) and the examples ping_server and ping_client (without changing anything).

The problem is that the communication fails. If I connect the nano as a server and a mega as a client, mega sends the message to the nano, it receives and sends the replay although but mega not receives and displays a timeout.

If I do the contrary, the mega as a server and nano as a client, the nano sends the message and the mega does nothing.

At the time I thought of any of the Nrf24L01 + bad but I have exchanged and error remains the same so it is clear that the problem has to be in the mega arduino that is unable to receive any message.

And after that summarize, someone has managed to use an arduino Nrf24L01+ with and mega with the library "Mirf" or with another library.

Thank you.

can we interface a webcam and a PIR motion sensor to an arduino...???

Can we interface a webcam and a PIR motion sensor with an Arduino…?

I want to connect a PIR motion sensor and a webcam to an Arduino…

when a human enters a specified region…the PIR motion sensor will send a signal to the Arduino…
the Arduino then sends an actuating signal to the webcam so that it switches ON and starts recording…

when the human moves out of the specified region…the PIR motion sensor will send another signal to the Arduino

the Arduino then controls the webcam by turning It OFF…

also is it possible to store the recorded video in a storage device (preferably SD card)…?

please help me…

Why Op Amp is Operational Amplifirer?

Can anyone help me,

Why Op Amp is called "Operational Amplifier" ?

Is Instrumentation Amplifier is not Operational Amplifier?

Please explain in your own words.

Thanks,
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir