Want to learn microcontroller use & programming to glow LEDs in scale model cars

Hello guys,

I want to install lights to miniature scale model of cars and bikes. I currently use external breadboard to control LEDs using DIP switches and i blink turn indicators using 555 timer.

here's my current setup:

4 X 3mm white LED (headlamps)
2 X SMD LED (pilot lamps)
2 X 5mm LED (angel eyes setup)
4 X SMD LED (turn indicators, i use 555 timer to blink them)
2 X 3mm LED (tail lamp)
2 X SMD LED (internal cockpit lamp and console light)

I want to learn microcontroller programming so i can integrate all components inside the model and use IR remote control (or maybe bluetooth of cellphone) to control all the LEDs.

I am n00b in electronics but i know basic circuit and its components, I have never worked with microcontroller before. I need some information about where to start. I searched for hours but i only found tutorials involving robotics or relay based light controller (110-220V home lights). since i want to glow only LEDs, i don't need relay i suppose?

I don't want to go into advanced robotics and such stuff.

I intend to use atmega8 uC. I don't have too much knowledge if this can handle my requirements. Any help will be highly appreciated.

Hello

Welcome to the World of the small scale.

For Starters I recommend the following Links:
Arduino Getting Started Guide: http://arduino.cc/en/Guide/HomePage
Arduino Examples: http://arduino.cc/en/Tutorial/HomePage (Start on the top left and work your way through....)

You'll probably need an ArduinoMega, as the UNO only provides 14 Digital I/O pins, but you need at least 16 (one per LED)

riesens:
Hello

Welcome to the World of the small scale.

For Starters I recommend the following Links:
Arduino Getting Started Guide: http://arduino.cc/en/Guide/HomePage
Arduino Examples: http://arduino.cc/en/Tutorial/HomePage (Start on the top left and work your way through…)

You’ll probably need an ArduinoMega, as the UNO only provides 14 Digital I/O pins, but you need at least 16 (one per LED)

Thanks alot for your reply.

Does adruino board mega 2560 require a programmer? or can i just hook it up with my PC via USB?

Is there any beginner friendly board with removable microcontroller (DIP type). So i can use microcontroller with perfboard?

Can i hook up two LEDs per pin? like two tail lamps that need to glow together connected to one pin of uC. If i can, I will only need 8 pins for my whole setup. 14 digital I/O pins would be enough in that case?

Hi hgps

Do you need to individually switch EACH of those LEDs? I assume that the headlamps, for example, are either all on or off.

If you can group the LEDs, you will need fewer I/O pins, which brings the project back into Uno territory. But you may well need external transistors to provide enough current to power multiple LEDs from one pin. One Arduino pin can sink max 40mA.

Example here: http://www.ecs.umass.edu/ece/m5/tutorials/multiple_LEDs_tutorial.html

What supply voltage and series resistor value do you use in your current setup?

The Nano is in DIP format and is USB programmable.

If you do go Mega, you program it from the Arduino IDE via USB, like the Uno.

Regards

Ray

If you want to fit your Arduino inside a model car then you probably want one of the small formats, or even just a bare Atmega 328 chip on your own circuit board.

This Thread about IR data transmission may be useful. I used it with an Attiny to make a receiver for an N-Gauge railway wagon. I did not have space for a PCB so everything was directly soldered to the Attiny pins.

I suggest you get an Arduino Uno to start with and learn on as it is the most standard - most things are designed for it. When you have your project working you can then miniaturize it if necessary.

This Thread about planning and implementing a program may be useful. It also illustrates how to use millis() to manage timing, which is essential if you want several things at a time to happen.

...R

Hackscribble:
Hi hgps

Do you need to individually switch EACH of those LEDs? I assume that the headlamps, for example, are either all on or off.

What supply voltage and series resistor value do you use in your current setup?

Regards

Ray

No, i will control lights as a pair. like a pair of tail lamps, a pair of HID projector lights, a pair of reflector type lights, a pair of pilot lamps etc. So i will need only 8 individual control of these LEDs.

I use 9V battery with 220ohm resistors per two LEDs in series. current hovers around 13-14mA. Its not finalised yet, i might increase resistance to dim the LEDs as they are still too bright.

Is there any beginner friendly board with removable microcontroller (DIP type). So i can use microcontroller with perfboard?

I intend to use atmega8 uC

Don’t use the atmega8. I don’t know if you meant to say "atmega328 but if you didn’t , you should
have.

Use the ATmega328 because ALL the arduino UNO circuit and code examples online will work with that chip because it is the chip used on the UNO.

The easiest method for a beginner is to buy an ATmega328 DIP with an OPTIBOOT bootloader preinstalled.
DIPMICRO ATmega328 with OPTIBOOT bootloader and buy an FTDI BASIC (5V version)
to upload the sketches. (UNO uses surface mount FTDI chip so you need an FTDI breakout to perform that function). After installing the USB driver on your computer you will be able to upload sketches to the DIP.
See this for atmega328 DIP breadboarding instructions.

Also, you might want to consider using ATtiny85s (8-pin DIP). Without knowing the current requirements
of you leds I don’t know if this chip will work for you. The same thing applies with this chip regarding the use of transistors for driving loads greater than the I/0 pins can handle.

DC Current per I/O Pin … 40.0 mA

ATtiny85 DATASHEET

You may want to research the boards file configuration setup for using the internal oscillators instead of
external crystal. This feature is available on both types of chip.
ATMEGA328 with INTERNAL OSCILLATOR

raschemmel:
The easiest method for a beginner is to buy an ATmega328 DIP with an OPTIBOOT bootloader preinstalled.
to upload the sketches. (UNO uses surface mount FTDI chip so you need an FTDI breakout to perform that function). After installing the USB driver on your computer you will be able to upload sketches to the DIP.

Thanks for your help

I can't find ATmega328 DIP with OPTIBOOT in my country. Only ATmega328 DIP with arduino UNO bootloader is available.
ATmega 328 with UNO bootloader

I can't find FTDI breakout either. Will TTL boards work? like this:
USB To RS232 PL2303 TTL Converter

I am thinking about buying Arduino pro mini or arduino nano as both will fit inside 1:10 bike models as well as car models, this will eliminate the requirement of using bare DIP ATmega328 and other hassles.

Nano is bigger but features USB port. Does that mean i don't have to have the hassle of finding FTDI breakout board you said above?

I would prefer arduino pro mini if it will work with TTL board i posted above since its smaller (will leave space to integrate battery inside the body)

Will this IR receiver work with arduino pro mini or nano?
HX1838 receiver NEC

or should i just buy this IR receiver and build supporting circuit myself :fearful:
TSOP 1738

I can't find ATmega328 DIP with OPTIBOOT in my country. Only ATmega328 DIP with arduino UNO bootloader is available.
ATmega 328 with UNO bootloader

I can't find FTDI breakout either. Will TTL boards work? like this:
USB To RS232 PL2303 TTL Converter

Optiboot is the bootloader

You have identified the parts you need.

...R

i bought an uno R3 for building circuit and pro mini (to install inside the car model). Worked with some simple circuits and it works fine. TSOP 1738 is also detecting signals as intended. I will use NPN 2N2222 as switch to control lights so that part has been taken care of.

I want to clear a few doubts before i buy some more components.

  1. Can i safely power arduino pro mini with 9V battery or 9V wallwart adaptor using RAW pin? or should i use an external 5V regulator and supply 5V to vcc pin?

  2. Is it possible to play analog sound using PWM? sorry if this sound n00bish as i have zero experience with arduino. I want to install speakers inside my car models and play exhaust sound clips to simulate engine sounds. If not, what options do i have to play audio clips of engine sounds?

I can't find FTDI breakout either. Will TTL boards work? like this:
USB To RS232 PL2303 TTL Converter

That doesn't have the DTR signal so you would have to do a manual reset after uploading a sketch.

sb/ttl…

youtube Arduino tutorials (15)…

Still no DTR, hence no RESET after upload. You will need to manually reset it after upload unless you have a true FTDI with a DTR pin.

DTR
Rxd
Txd
+5V
GND
3V3

Ok. I see it now. That'll work.

raschemmel:
That doesn't have the DTR signal so you would have to do a manual reset after uploading a sketch.

that was 1 month old post :stuck_out_tongue: I got it sorted. had to hold reset button till arduino IDE starts showing 'uploading'.

My questions are:

  1. Can i safely power arduino pro mini with 9V battery or 9V wallwart adaptor using RAW pin? or should i use an external 5V regulator and supply 5V to vcc pin?

  2. Is it possible to play analog sound using PWM? sorry if this sound n00bish as i have zero experience with arduino. I want to install speakers inside my car models and play exhaust sound clips to simulate engine sounds. If not, what options do i have to play audio clips of engine sounds?

  1. Yes. Make sure it's DC, not AC.

  2. Yes. Easier to play more than a fraction of a second by controlling some external hardware tho, like one of these:
    MDFLY - Search Results for "mp3"
    Record your sound, store it as file 001.mp3. Send that number to the card, it plays it back.

How big are the models?

If you bothered to look at the links I posted you would already know. (First 2 lessons)

9V wallwart (if it is DC) should be ok.

PWM not designed for sound, designed for dimming LEDs and controlling motor speed etc.

@Bluejets: sorry, missed your link in that usb to ttl link and attached picture.

CrossRoads:

  1. Yes. Make sure it's DC, not AC.

  2. Yes. Easier to play more than a fraction of a second by controlling some external hardware tho, like one of these:
    MDFLY - Search Results for "mp3"
    Record your sound, store it as file 001.mp3. Send that number to the card, it plays it back.

How big are the models?

Around 9 inches long. Has enough room for arduino pro mini, speaker, amplifier and mp3 module.