Skip to end of metadata
Go to start of metadata


We have received and finally open the Educational Kit, Thanks to the support of RS-Components.

The kit with all the tutorial can be found on the rs-online page, here the nice picture  with Massimo Banzi that you know.
I posted here also the list of the videos because the projects are really whell defined from the simplest one to a lamp that can be controlled via twitter.


 But back to the educational kit,

 it has  a very complete  set of different components, that allow a lot of different experiments:

| | |

The kit has a very well done book with a lot of pictures that help the understanding of the different devices and the connectivity on the breadboard

                          

The kit has  a lot of components also in quantity, like the 6 photoresistors.

| |

To start to get familiar with the kit I decided to create something simple, using some of the most standard components,

I created a LED visualization system for the position of a servo.

To start I placed a set of LED in a  circle and I connected them to Arduino:


The code is very simple, I connected the LED in sequence starting from port 2 to port 9,

the LED0 is equal to 2 and I am starting looping on 2 to 9 and resetting the previous LED,

using the prev variable .

Icon

for(j=0;j<2;j++) {
   for(i=0;i<8;i++) {

    if (i!=0)  {prev=i-1;}  else  {prev=9-2;}

       digitalWrite(LED0+prev,LOW);
       digitalWrite(LED0+i,HIGH);
       delay(50);
     }}

Second step of the example is to control the  LED using the variable resistance ,

to do that first you need to connect the resistor to one analog input and send the reading to the serial port for Arduino

to display it , here you can see the video of my tests on the serial port reading , and the final results:

The code is a bit more complicated,

you need to read the analog input and send the results on the serial port ,

read the values with the monitor and adjust the min max values based on what you read,

in my case the min was 0 and the max was 470. 

Icon

val=analogRead(A5);
Serial.println(val);

if (val>r0L && val<r0H) { all_off; digitalWrite(LED7,HIGH); }
if (val>r1L && val<r1H) { all_off; digitalWrite(LED6,HIGH); }
if (val>r2L && val<r2H) { all_off; digitalWrite(LED5,HIGH); }
if (val>r3L && val<r3H) { all_off; digitalWrite(LED4,HIGH); }
if (val>r4L && val<r4H) { all_off; digitalWrite(LED3,HIGH); }
if (val>r5L && val<r5H) { all_off; digitalWrite(LED2,HIGH); }
if (val>r6L && val<r6H) { all_off; digitalWrite(LED1,HIGH); }
if (val>r7L && val<r7H) { all_off; digitalWrite(LED0,HIGH); }

I am using a lot of define because I like them , the analog reading "val"

is compared to the different thresholds that are stored in the initial define 

like also the LED port numbers ..

Icon

#define LED0 2
#define LED1 3
#define LED2 4
#define LED3 5
#define LED4 6
#define LED5 7
#define LED6 8
#define LED7 9

#define r0L 0
#define r0H (470/8)
#define r1L (470/8)
#define r1H (470/8*2)
#define r2L (470/8*2)
#define r2H (470/8*3)
#define r3L (470/8*3)
#define r3H (470/8*4)
#define r4L (470/8*4)
#define r4H (470/8*5)
#define r5L (470/8*5)
#define r5H (470/8*6)
#define r6L (470/8*6)
#define r6H (470/8*7)
#define r7L (470/8*7)
#define r7H (470/8*8)

#define all_off   digitalWrite(LED0,LOW); digitalWrite(LED1,LOW);  digitalWrite(LED2,LOW);  digitalWrite(LED3,LOW);  digitalWrite(LED4,LOW);  digitalWrite(LED5,LOW); digitalWrite(LED6,LOW);  digitalWrite(LED7,LOW);

Last step is to add the needed servo infrastructure and drive not only the LED but also the servo with

the correct angle . The program is not finish and should be adjusted becasue the servo can rotate only 180 degree,

but the LED are rotating 360 degree , I need to turn on two LEDs together

Icon

#include <Servo.h>

....

Servo myservo;

.....

void setup(void)  {

....

myservo.attach(10);
  myservo.write(0);

....

}

void loop(void) {
val=analogRead(A5);
Serial.println(val);
if (val>r0L && val<r0H) { all_off; digitalWrite(LED7,HIGH);  myservo.write(0);}
if (val>r1L && val<r1H) { all_off; digitalWrite(LED6,HIGH);  myservo.write(25.71);}
if (val>r2L && val<r2H) { all_off; digitalWrite(LED5,HIGH);  myservo.write(51.42);}
if (val>r3L && val<r3H) { all_off; digitalWrite(LED4,HIGH);  myservo.write(77.14);}
if (val>r4L && val<r4H) { all_off; digitalWrite(LED3,HIGH);  myservo.write(102.86);}
if (val>r5L && val<r5H) { all_off; digitalWrite(LED2,HIGH);  myservo.write(128.57);}
if (val>r6L && val<r6H) { all_off; digitalWrite(LED1,HIGH);  myservo.write(154.29);}
if (val>r7L && val<r7H) { all_off; digitalWrite(LED0,HIGH);  myservo.write(180);}
}

To start to get familiar with the kit I decided to create something simple, using some of the most standard components ,
I created a LED visualization system for the position of a servo .

To start I placed a set of LED in a  circle and I connected them to Arduino:

 

Next step is to place a couple of photoresistors on top of the servo and detect the direction with maximum light value.

It is needed also to compensate the rotation , because the servo is rotating only of 180' and the variable resistance of ~300'  and the LED of 360'

It is needed to adjust the values. The code is also not very efficient , because it uses a list of if statement,

it could be concerted few lines of code , using bit shift functions and a threshold function. 

This will be for the next time.

Here attached my code:EDUCATIONAL_led_round.ino


  • No labels