10
Oct 13

Chapter 26 – Experiment 18 – SMOOTHING WHEN READING DATA

The smoothing of the data is use normally when an input has a fast and huge variation of values trying to keep a quite stable value. Imagine like a wave where you need to read the highest point in a specific position. The value probably if the weather is bad is changing quite fast.

You can consider the smoothing like a simple filter that given a specific number of readings is returning the average value.

For the breadboard and schema is possible to use the ones on experiment 04, experiment 20 and experiment 21.

The code is here:
int sensVal; // for raw sensor values
float filterVal; // this determines smoothness – .0001 is max 1 is off (no smoothing)
float smoothedVal; // this holds the last loop value just use a unique variable for every                                           different sensor that needs smoothing

float smoothedVal2; // this would be the buffer value for another sensor if you needed to                                         smooth two different sensors – not used in this sketch

int i, j; // loop counters or demo

void setup()

{
Serial.begin(9600);
Serial.println(“start “);
}

/* the main loop is a test of the smooth function. It generates a simulated square wave and then
switches in four different smoothing values. Watch the numbers scroll by as the filter value
slows down the response. */

void loop()
{
for (i = 0; i < 7; i++){ // substitute some different filter values
filterVal = i * .15;

for (j = 0; j< 60; j++){

if (j < 30){ // generate a simulated square wave

sensVal = 1023;
}
else

{

sensVal = 0;
}

// sensVal = analogRead(0); this is what one would do normally
smoothedVal = smooth(sensVal, filterVal, smoothedVal); // second parameter                                                            determines smoothness – 0 is off, .9999 is max smooth

Serial.print(sensVal);
Serial.print(” “);
Serial.print(smoothedVal, DEC);
Serial.print(” “);
Serial.print(“filterValue * 100 = “); // print doesn’t work with floats
Serial.println(filterVal * 100, DEC);
delay(30);
}
}
}

int smooth(int data, float filterVal, float smoothedVal){

if (filterVal > 1){ // check to make sure param’s are within range
filterVal = .99;
}
else if (filterVal <= 0){
filterVal = 0;
}

smoothedVal = (data * (1 – filterVal)) + (smoothedVal * filterVal);

return (int)smoothedVal;
}
 


10
Oct 13

Chapter 28 – Experiment 20 – POTENTIOMETER

This example will teach you how to use a potentiometer.

The potentiometer is a simple knob that provides a variable resistance, which can be read by the micro-controller as an analog value. You can imagine to have an infinite number of resistors that based on the knob are returning a different resistance value. By turning the shaft of the potentiometer, the the amount of resistance is changed. The central pin is used for read the analog value of the potentiometer.

The breadboard:

20 - POTENTIOMETER

The schema:

20 - potentiometer (1)

Finally, the code:

int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup()
{ // declare the ledPin as an OUTPUT:
   pinMode(ledPin, OUTPUT);
}
void loop()
{ // read the value from the sensor:
  sensorValue = analogRead(sensorPin);
  // turn the ledPin on
  digitalWrite(ledPin, HIGH);
  // stop the program for <sensorValue> milliseconds:
  delay(sensorValue);
  // turn the ledPin off:
  digitalWrite(ledPin, LOW);
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);
}

08
Oct 13

Chapter 19 – Experiment 11 – DISCO PARTY

Do you want to make a disco party at home but you cannot make the right atmosphere? Arduino can help you with this simple experiment!

LEDs are great. But with any project there comes a point where flashing is simply not enough. For these cases an RGB (Red, Green and Blue) LED is the right answer. With an RGB LED you’ll be able to produce any colour glow you desire.

At first using an RGB LED seems quite complex, but it quite quickly becomes clear that its no more difficult than controlling one of their single colour LED.

An RGB LED is simply a three LEDs crammed into a single LED package using four wires. There is one led for each red, green, and blue element. These three colors share the same (anode or catode, it depends on the type of led) terminal, which means that this RGB LED has a “common anode” connection. With the control of the intensity using the Pulse Width Modulation (PWM) you can create all the colors of the rainbow.

Ok, so now is time to party!

The breadboard should look like this:

11 - DISCO - RGB

 

The schema:

11 - DISCO PARTY - RGB

 

 

The Code for doing this:

int redPin = 12;
int greenPin = 11;
int bluePin = 10;
void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop()
{
setColor(255, 0, 0); // red
delay(1000);
setColor(0, 255, 0); // green
delay(1000);
setColor(0, 0, 255); // blue
delay(1000);
setColor(255, 255, 0); // yellow
delay(1000);
setColor(80, 0, 80); // purple
delay(1000);
setColor(0, 255, 255); // aqua
delay(1000);
setColor(255, 255, 255);
delay(1000);
}
void setColor(int red, int green, int blue)
{
for(int fadeValue = 0 ; fadeValue <= red; fadeValue +=5)
{ // sets the value (range from 0 to 255):
analogWrite(redPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
for(int fadeValue = 0 ; fadeValue <= green; fadeValue +=5)
{ // sets the value (range from 0 to 255):
analogWrite(greenPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
for(int fadeValue = 0 ; fadeValue <= blue; fadeValue +=5)
{ // sets the value (range from 0 to 255):
analogWrite(bluePin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
}

 


05
Jun 13

Chapter 27 – Experiment 19 – HELLO! HELLO! HELLO!

From Wikipedia (http://en.wikipedia.org/wiki/Morse_code):

“Morse code is a method of transmitting text information as a series of on-off tones, lights, or clicks that can be directly understood by a skilled listener or observer without special equipment. The International Morse Code encodes the ISO basic Latin alphabet, some extra Latin letters, the Arabic numerals and a small set of punctuation and procedural signals as standardized sequences of short and long signals called dots and dashes”

This experiment introduce to you to Morse code, that is used from long time in the communication field. The code will be in updated with some interactivity and in future experiments, in the advanced kit, you will be able to exchange data with other microcontrollers/kits using different communication channels.

The circuit is the same as Experiment 01.

/*
WE MAKE IT – Morse code, Experiment 19

Original version from:
Morse Code Flasher
Written for bit-tech.net / Custom PC
*/

int ledPin = 12; /* Pin 12 is the external circuit used in the experiment 01, Pin 13 is the pin on the board */

void setup() /* Where the defaults are set */
{
pinMode(ledPin, OUTPUT);
}

void loop() /* Where the meat of the program goes */
{
HELLO();
}

void HELLO() {

dot(); dot(); dot(); dot(); letterpause();   // H
dot(); letterpause();   // E
dot(); dot(); dot(); dot(); letterpause();   // L
dot(); dot(); dot(); dot(); letterpause();   // L
dot(); dash(); dot(); dot(); letterpause();   // O

wordpause();
}

void dot() /* Define a ‘dot */
{
digitalWrite(ledPin, HIGH);
delay(250);
digitalWrite(ledPin, LOW);
delay(250);
}

void dash() /* Define a ‘dash’ */
{
digitalWrite(ledPin, HIGH);
delay(750);
digitalWrite(ledPin, LOW);
delay(250);
}

void letterpause() /* Insert a pause between letters */
{
delay(500);
}

void wordpause() /* Insert a pause between words */
{
delay(1500);
}


18
May 13

Workshop in Prizren

WMKIT workshop Open Labs and FLOSSK

After Tirana, Athens, Prishtina and Crete WMKIT, the innovative educational kit initiated in Albania, visited Prizren (Kosovo) in order to make youngsters in the city learn and play with electronics and programming. Open Labs and FLOSSK teamed together once more for this event that aimed to open horisons to kids of all ages.
Big thanks everyone for the presence and Besfor Guri and FLOSSK for arranging this!

Where: University of Prizren, Prizren (Kosovo)
When: 17.05.2013 @ 10.30
Links: Facebook event, Google+ event, article source openlabs.cc

WMKIT workshop Open Labs and FLOSSKOpen Labs prizren


istanbul evden eve nakliyat istanbul evden eve nakliyat istanbul evden eve nakliyat sarıyer evden eve nakliyat beylikdüzü evden eve nakliyat şişli evden eve nakliyat