Delivery throughout Europe

Ordered before 16:00 = Shipped today

Fast delivery with DHL

XNUMX days return *


Country

This is the 17th project from the Starter kit for Arduino.

You will learn how to control 3 LED lights with a Arduino Uno and a touch sensor.
This is an easy project that you can finish in about 15 minutes. But this is also an excellent project to make adjustments yourself is the code so that the on and off with a different pattern.

  • Level - Basic 15% 15%
  • Duration - 10/20 Min 15% 15%
  • Costs - € 56.35 euros complete 40% 40%

Step 1: Requirements

  • USB 2.0 cable with A / B connection - 1,8m

    2,99 /2,47 excl. VAT
  • Arduino Uno rev3

    Arduino Uno Rev3 – ATMEGA328

    23,95 /19,79 excl. VAT
  • starter_kit_for_arduino_8

    Starter kit for Arduino

    29,95 - 53,91
  • USB 2.0 cable with A / B connection - 1m

    2,44 /2,02 excl. VAT
  • USB 2.0 cable with A / B connection - 4,5m

    4,99 /4,12 excl. VAT

Step 2: Building and Wiring

Now we are going to put the project together.
We start with wiring and placing the components on the breadboard do this according to the photo above. Place the touch sensor in such a way that you can easily reach it.

When you turn the touch sensor, you must also reverse the order of the wires.

The 3 LEDs all need a 220k resistor because the voltage across the LEDs gets too high and breaks it.
If you do this, the resistor must be connected to the + pin of the LEDs. You can recognize the + pin because it is longer than the -pin.

Once you have connected all components to the bread according to the schematicboard you can connect everything to the Arduino.

It is important that you connect everything in the right place if this does not happen, the code does not work.

GND TS -> GND
VCC TS. -> 5V
SIG TS -> pin 2
B LED + -> pin 3
R LED + -> pin 5
G LED + -> pin 6

Step 3: Programming

You have now wired and connected everything neatly. So we can start programming.

You can easily copy the code below to the Arduino IDE and then upload it to the Arduino.

You know the code is correct if your project does the following:

1st touch: B LED turns on, the rest remains off
2nd touch: B LED goes out, R LED goes on, G LED stays off
3rd touch: R LED goes out, G LED goes on, B LED stays off
4th touch: All LEDs turn on then R LED turns off and on again, after which B & G LED turns off and on. This keeps repeating itself.
5th touch: All LEDs go out

The code is now complete and will start again from the beginning.

/*
* Author: Elecrow Engle
* Date:7/21/2017
* IDE V1.8.2
* Email: engle@elecrow.com
*Function:
*/
const int touch = 2;
const int Bled = 3;
const int Rled = 5;
const int Gled = 6;
//in last time=0;
//int val=0;
int count = 0;

void setup ()
{
analogWrite (Bled, 0);
analogWrite (Rled, 0);
analogWrite (Gled, 0);
attachInterrupt(0, swRGB, RISING);
}

void loop ()
{
switch(count)
{
case 1:
analogWrite (Bled, 255);
analogWrite (Rled, 0);
analogWrite (Gled, 0);
delay (500);
break;
case 2:
analogWrite (Bled, 0);
analogWrite (Rled, 255);
analogWrite (Gled, 0);
delay (500);
break;
case 3:
analogWrite (Bled, 0);
analogWrite (Rled, 0);
analogWrite (Gled, 255);
delay (500);
break;
case 4:
RGBflash ();
break;
case 5:
analogWrite (Bled, 0);
analogWrite (Rled, 0);
analogWrite (Gled, 0);
delay (500);
break;
}
}

void swRGB()
{
count + +;
if (count> 5)
count = 0;
}

void RGB flash()
{
for (int c=0,b=255,a=0; c<=255,b>0,a<=255;c++,b–,a++){
analogWrite (Bled, c);
analogWrite (Rled, b);
analogWrite (Gled, a);
delay (5);
}
for (int a=255,b=0,c=255; a>0,b<=255,c>0;a–,b++,c–){
analogWrite (Bled, c);
analogWrite (Rled, b);
analogWrite (Gled, a);
delay (5);
}
}

You have now successfully completed the project.

If you like you can adjust the code and give the lamp more functions.

The rating of www.elektronicavoorjou.nl at WebwinkelKeur Reviews is 9.3/10 based on 4990 reviews.