Project tutorial

Multi-Source Controlled USB Lamp © GPL3+

An ATtiny-based tiny USB lamp that can be turned on/off by knocking, clapping, blowing, finger snapping and shouting.

  • 997 views
  • 2 comments
  • 12 respects

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
×1
Adafruit industries ada64 image 75px
Solderless Breadboard Half Size
×1
Attiny85
Microchip ATtiny85
×1
10uF electrolytic capacitor
×1
Male/Male Jumper Wires
×1
Microphone Sound Sensor
LM393 Microphone sound Sensor
×1
Kingbright wp7113srd d image
5 mm LED: Red
I used a white LED
×1
220 ohm resistor
The value of resistor in series with LED may be a different value than 220 ohm ,the LED will lit up also with values up to 1k ohm.
×1
IC Socket
×1
Perfboard
×1
Adafruit industries ada592 image 75px
USB-A to Micro-USB Cable
×1

Necessary tools and machines

Soldering Iron
Utility knife
Hot glue gun
A bottle cap and a white paper

Apps and online services

About this project

If you don't mind having a bit of fun with electronics this project is for you. In this project, I am making an ATtiny-based USB lamp that can be turned off/on by multiple sources such as:

  • Knocking
  • Clapping
  • Blowing
  • Finger Snapping
  • Shouting
  • In this project I utilized, or I can say I misused, microphone sound sensor to detect different sources to turn on and turn off lamp. Also I wanted to make this project as small as possible, so I used a ATtiny 85 microconntroller. This is cool because the ATtiny is tiny, and - well - this allows you to make tiny things that don't need a big micro controller.

Basic Idea

A microphone is an acoustic to an electric transducer or sensor that detects sound signals and converts them into an electrical signal.

To generate an electrical signal all you need to do is make movements in the diaphragm. So when blowing on a microphone sound sensor, microphone’s diaphragm responds because it is a displacement of air molecules pushing on one side of the membrane to the other causing electrical signal in the microphone to make it seem like sound.

Also here I am describinghow to program ATtiny microcontrollers using the Arduino IDE.

Let's get started...

Watch the Video

The video goes through the build process as well,if you prefer to learn that way!

Get the Parts and Materials!

You will need following parts to flash ATtiny through Arduino:

  • Arduino
  • Breadboard
  • ATtiny85 (or ATtiny45)
  • 10uF electrolytic capacitor
  • Jumper Wires

You will need following parts to build the final circuit:

  • ATtiny85
  • Microphone Sound Sensor
  • LED
  • 220 ohm resistor
  • IC socket
  • Perfboard
  • USB Cable

Note:

The value of resistor in series with LED may be a different value than 220 ohm, the LED will lit up also with values up to 1k ohm.

Other Tools and Materials

  • Glue Gun
  • Utility Knife
  • Bottle Cap
  • A white paper
  • Soldering Iron

Wire the Circuit to Flash ATtiny

Connect the Arduino to the ATtiny as follows:

  • Arduino +5V ---> ATtiny Pin 8

  • Arduino Ground ---> ATtiny Pin 4

  • Arduino Pin 10 ---> ATtiny Pin 1

  • Arduino Pin 11 ---> ATtiny Pin 5

  • Arduino Pin 12 ---> ATtiny Pin 6

  • Arduino Pin 13 ---> ATtiny Pin 7

Put the 10uF capacitor between ground and the Arduino reset pin. Make sure to keep an eye on the capacitors polarity (ground to ground!).

This capacitor effectively filters out the incoming reset pulses that come from your PC when the Arduino software starts to program your part. Because you want to program a part further downstream, you filter the reset pulses coming into the Arduino. Otherwise, you’d invoke the Arduino’s bootloader and program that Arduino, and that’s not what you want at all;);

Set Up Arduino IDE

  • Connect your Arduino, open the IDE, and upload Example> ArduinoISP sketch;

This Arduino-supplied example sketch turns your Arduino into an ISP (in-system programming)

Again ;

  • Open Arduino IDE
  • File > Preferences and in Additional Board Manager URLs: and Copy/Paste this:

https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json

  • Click OK
  • Tools > Board > Manager, install: ATTiny and close Arduino IDE.

Configure Arduino IDE Tools Menu

Open Arduino IDE,

(1)Board: ATtiny25/45/85

(2)Processor: ATtiny85

(3)Clock: Internal 1 MHz

(4)Port: COMXX(Arduino Uno)

(5)Programmer: Arduino as ISP

Upload the below given code:

int led =0;
int sensor=1;
int state1=HIGH;
boolean value=0;
int state2=LOW;
void setup()
{
 pinMode(led,OUTPUT);
 pinMode(sensor,INPUT);
}
void loop()
{
value=digitalRead(sensor);
if(value==HIGH && state2==LOW)
{
 if(state1==HIGH)
   state1=LOW;
 else
   state1=HIGH;
}
digitalWrite(0,state1);
state2=value;
}

Also you can get Code and circuit diagram from my Github page.

The Prototype!

I build a prototype on a breadboard to test the circuit.Follow the circuit circuit diagram to complete the breadboard connection.

And it worked Fine:)

Note:If the led is not lighting up, you need change the sensor sensitivity (reduce Sensitivity) by rotating the potentiometer.

Breadboard to Perfboard

I cut perfboard into a size of coin and I soldered all parts into it.I soldered a usb cable, so I can power it from any USB Ports such as laptop, power bank etc.

Building Base and Lamp Shade

I decided to build a base and lamp shade.For that I used a bottle cap and a piece of white paper.

  • By using a utility knife cut out some portion from bottle cap to insert usb's wire through it.
  • Fix the circuit into bottle cap using hot glue gun.
  • Get a white paper and join it using hot glue.It must look like a hollow cylinder.
  • Insert the paper through top of circuit and join it with hot glue.

Thank you so much for reading if you need any more information feel free to ask in comments, and I'll do my best answer you.

:)

Code

Schematics

program_an_attiny_with_arduino_bb_X0eKMZIjs4.png
Program an attiny with arduino bb x0ekmzijs4
program_an_attiny_with_arduino_schem_ccn2noCxBz.png
Program an attiny with arduino schem ccn2nocxbz
circuit_YthuIdQEsn.png
Circuit ythuidqesn
attiny45-85_LVen0x4QCi.jpg
Attiny45 85 lven0x4qci

Comments

Similar projects you might like

Remote Controlled Smart Lamp

Project tutorial by gadget programmers

  • 3,716 views
  • 1 comment
  • 14 respects

Arduino Controlled USB Trackpad

Project tutorial by Dante Roumega

  • 7,657 views
  • 6 comments
  • 10 respects

Voice Controlled RGB Lamp

Project tutorial by Pham Hoang Son

  • 2,721 views
  • 0 comments
  • 11 respects

"Living Art" Arduino-Controlled Desk Lamp

Project tutorial by Modustrial Maker

  • 8,502 views
  • 2 comments
  • 23 respects
Add projectSign up / Login