22 Temmuz 2015 Çarşamba

There are similar projects i saw but I did it much more complicated and developed. You will recognize how it works after you examine the schema and video added.Note that I did not waste my arduino. It is not necessary for this circuit.
Material List

  • 2 x Float switch - I bought them from Ebay about 2 dollars.
  • 1x 12V 1A DC Power Supply
  • 1x Sump Pump
  • 1x12v Relay ( In order to control 220V cause we don't want to give our float switches 220V directly it is dangerous.)
  • 1x Check Valve (If your pump is lower than your tank, you should use it to protect water returning to backet again)
  • 1xLED
Why should relay be used ?
Float switches cannot be given 220 V AC directly It can deal with max 30 V (for security) and it is also dangerous cause our switches staying in the water so we are using 12V on switches and theycontrol the pump. It makes our system more secure. The switches works like AND gate. In order to pump water, both of switches must be closed(on transmission). If one of them is open, It wont pump. When 12 Volt goes relay(2 of switches are closed) relay will provide 220V transmission. You can also think relay as a switch.

Note : You should connect float switch itself which is in the bucket as reverse.(see schema) Cause while sensor in the tank should work when water is lower, the sensor in the bucket should not work if water is lower.(to protect motor waterlessness).

Video




14 Mayıs 2015 Perşembe

Arduino Project - Guide stick for blind people.



Guide Stick

Summary : We have built a smart stick for blind people to inform blind people by using 3 UltraSound Sensors. For unused times, we make arduino asleep to save power and wake up it just by pushing a button. We used timer to control sensor, interrupt to control sleep / wakeup and eeprom for different Modes.

Design :













Schema





As it is shown above, to measure right distance we will use Sensor1, for left we will use Sensor 2 and for front distance, we will use Sensor3. Arduino will be attached at the center of circle. There will be a stimulative which is buzzer; when one of the sensors is close enough to an object, buzzer will warn person. In this project we will also use;

Requirements :

  •          1x Buzzer
  •          3x UltraSound Sensor
  •          1x Button
  •          1x Arduino
  •          1x Stick
  •          1x 9V battery
  •          2x LED
Timer : To control sensor, check interval.
Interrupt : Checks inactivity time / sleeps arduino.
EEPROM : Saves configuration / Loads configuration at the start
Button :  To change mode of interrupt.

Implementation
Note : The code below is just important / wanted code. Not all codes included.
EEPROM.write(0,10); // We wrote the eeprom all modes that we used. 0. İndex has 10, 1. İndex 20 and 3. index has 30 cm.
EEPROM.write(1,20);   
EEPROM.write(2,30);
.
attachInterrupt(1, pin2_isr, LOW);   // When  clicked the button, arduino calls , pin2_isr method to wake up. It includes only “detachInterrupt(0); “
Timer1.initialize(750000);
Timer1.attachInterrupt(Sensor); // We used timer to call Sensor method every 750 ms. (It is optimum value for buzzer to work with no problem.

if(distance<border) {  // Which alarm triggered.
    AlarmCounter++;     
    if(AlarmCounter ==15) {  // To sleep arduino by using interrupt
.
     sleep_enable();
}
if (buttonState == LOW)
  {
      buttonCount++;
       if(buttonCount>3) {   // We want to have 3 modes so if it bigger than 3, we initiaize it to 1.
          buttonCount = 1;
          }
         if(buttonCount==1) {
              border = Config;  // if buttonCount = 1 (which is mode 1), we assign our border to first index of eeprom.
            }
            if(buttonCount ==2) {
                border = Config2;  // if buttonCount = 2 (which is mode 2), we assign our border to second index of eeprom.
                  }
             if(buttonCount == 3) {
                    border = Config3; }// if buttonCount = 3 (which is mode 3), we assign our border to third index of eeprom

Results

     In this project, we have built a guide stick to help blind people to understand whether there is an object around the stick or not. That can be useful for blinds to walk carefully. By constracting this project, we have learned how to use timer and interrupt and understand their methods / implementations. We also recognized that how to make arduino sleep by using interrupt. Cell phones that we use have the same process to wake up. So it was very beneficial for us to understand how cell phones are listening buttons. Furthermore, we examined the ultrasound sensors and researched their structure to understand how does that sensor measure distance by using ultra sound voice that beyond 20KHZ which a human cannot hear.


5 Nisan 2015 Pazar

Arduino Experiment 2: Reading a Potentiometer - Modify (One increases while another decreases- )

Definition : In this circuit we connected 2 leds and 1 potentiometer to arduino and control leds while frequency of red led increases and green decreases and vice versa depending on potentiometer's value.

Circuit Diagram


Components
1 x 10 k Potentiometer
2 x Led
Wires

Code

int sensorPin = 0;    // The potentiometer is connected to
                      // analog pin 0
int ledPin = 12;
int ledPin2 = 13;      // The LED is connected to digital pin 13



void setup() // this function runs once when the sketch starts up
{

  pinMode(ledPin, OUTPUT);
  pinMode(ledPin2, OUTPUT);


}


void loop() // this function runs repeatedly after setup() finishes
{

  int sensorValue;


  sensorValue = analogRead(sensorPin);  

  digitalWrite(ledPin, HIGH);     // Turn the LED on

  delay(sensorValue);             // Pause for sensorValue
    digitalWrite(ledPin, LOW);      // Turn the LED off

  delay(sensorValue);

    digitalWrite(ledPin2, HIGH);
    delay(1/sensorValue);
                                  // milliseconds

             // Pause for sensorValue
                                  // milliseconds
                               
    digitalWrite(ledPin2, LOW);      // Turn the LED off

  delay(1/sensorValue);


}


Video





Arduino Experiment 11: Using a Piezo Buzzer - Modify


Definition :In this project, we can play mario song by using buzzer. You can also play any song just by using a simple buzzer ! We can arrange all the notes and duration of them.

Circuit Diagram


Components
  • 1 x Buzzer
  • 1 x Led
  • 1 x Arduino Uno
Arduino Code

#define NOTE_B0  31
#define NOTE_C1  33
#define NOTE_CS1 35
#define NOTE_D1  37
#define NOTE_DS1 39
#define NOTE_E1  41
#define NOTE_F1  44
#define NOTE_FS1 46
#define NOTE_G1  49
#define NOTE_GS1 52
#define NOTE_A1  55
#define NOTE_AS1 58
#define NOTE_B1  62
#define NOTE_C2  65
#define NOTE_CS2 69
#define NOTE_D2  73
#define NOTE_DS2 78
#define NOTE_E2  82
#define NOTE_F2  87
#define NOTE_FS2 93
#define NOTE_G2  98
#define NOTE_GS2 104
#define NOTE_A2  110
#define NOTE_AS2 117
#define NOTE_B2  123
#define NOTE_C3  131
#define NOTE_CS3 139
#define NOTE_D3  147
#define NOTE_DS3 156
#define NOTE_E3  165
#define NOTE_F3  175
#define NOTE_FS3 185
#define NOTE_G3  196
#define NOTE_GS3 208
#define NOTE_A3  220
#define NOTE_AS3 233
#define NOTE_B3  247
#define NOTE_C4  262
#define NOTE_CS4 277
#define NOTE_D4  294
#define NOTE_DS4 311
#define NOTE_E4  330
#define NOTE_F4  349
#define NOTE_FS4 370
#define NOTE_G4  392
#define NOTE_GS4 415
#define NOTE_A4  440
#define NOTE_AS4 466
#define NOTE_B4  494
#define NOTE_C5  523
#define NOTE_CS5 554
#define NOTE_D5  587
#define NOTE_DS5 622
#define NOTE_E5  659
#define NOTE_F5  698
#define NOTE_FS5 740
#define NOTE_G5  784
#define NOTE_GS5 831
#define NOTE_A5  880
#define NOTE_AS5 932
#define NOTE_B5  988
#define NOTE_C6  1047
#define NOTE_CS6 1109
#define NOTE_D6  1175
#define NOTE_DS6 1245
#define NOTE_E6  1319
#define NOTE_F6  1397
#define NOTE_FS6 1480
#define NOTE_G6  1568
#define NOTE_GS6 1661
#define NOTE_A6  1760
#define NOTE_AS6 1865
#define NOTE_B6  1976
#define NOTE_C7  2093
#define NOTE_CS7 2217
#define NOTE_D7  2349
#define NOTE_DS7 2489
#define NOTE_E7  2637
#define NOTE_F7  2794
#define NOTE_FS7 2960
#define NOTE_G7  3136
#define NOTE_GS7 3322
#define NOTE_A7  3520
#define NOTE_AS7 3729
#define NOTE_B7  3951
#define NOTE_C8  4186
#define NOTE_CS8 4435
#define NOTE_D8  4699
#define NOTE_DS8 4978
#define melodyPin 8
//Mario main theme melody
int melody[] = {
  NOTE_E7, NOTE_E7, 0, NOTE_E7,
  0, NOTE_C7, NOTE_E7, 0,
  NOTE_G7, 0, 0,  0,
  NOTE_G6, 0, 0, 0,
  NOTE_C7, 0, 0, NOTE_G6,
  0, 0, NOTE_E6, 0,
  0, NOTE_A6, 0, NOTE_B6,
  0, NOTE_AS6, NOTE_A6, 0,
  NOTE_G6, NOTE_E7, NOTE_G7,
  NOTE_A7, 0, NOTE_F7, NOTE_G7,
  0, NOTE_E7, 0, NOTE_C7,
  NOTE_D7, NOTE_B6, 0, 0,
  NOTE_C7, 0, 0, NOTE_G6,
  0, 0, NOTE_E6, 0,
  0, NOTE_A6, 0, NOTE_B6,
  0, NOTE_AS6, NOTE_A6, 0,
  NOTE_G6, NOTE_E7, NOTE_G7,
  NOTE_A7, 0, NOTE_F7, NOTE_G7,
  0, NOTE_E7, 0, NOTE_C7,
  NOTE_D7, NOTE_B6, 0, 0
};
//Mario main them tempo
int tempo[] = {
  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,
  9, 9, 9,
  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,
  9, 9, 9,
  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,
};
//Underworld melody
int underworld_melody[] = {
  NOTE_C4, NOTE_C5, NOTE_A3, NOTE_A4,
  NOTE_AS3, NOTE_AS4, 0,
  0,
  NOTE_C4, NOTE_C5, NOTE_A3, NOTE_A4,
  NOTE_AS3, NOTE_AS4, 0,
  0,
  NOTE_F3, NOTE_F4, NOTE_D3, NOTE_D4,
  NOTE_DS3, NOTE_DS4, 0,
  0,
  NOTE_F3, NOTE_F4, NOTE_D3, NOTE_D4,
  NOTE_DS3, NOTE_DS4, 0,
  0, NOTE_DS4, NOTE_CS4, NOTE_D4,
  NOTE_CS4, NOTE_DS4,
  NOTE_DS4, NOTE_GS3,
  NOTE_G3, NOTE_CS4,
  NOTE_C4, NOTE_FS4, NOTE_F4, NOTE_E3, NOTE_AS4, NOTE_A4,
  NOTE_GS4, NOTE_DS4, NOTE_B3,
  NOTE_AS3, NOTE_A3, NOTE_GS3,
  0, 0, 0
};
//Underwolrd tempo
int underworld_tempo[] = {
  12, 12, 12, 12,
  12, 12, 6,
  3,
  12, 12, 12, 12,
  12, 12, 6,
  3,
  12, 12, 12, 12,
  12, 12, 6,
  3,
  12, 12, 12, 12,
  12, 12, 6,
  6, 18, 18, 18,
  6, 6,
  6, 6,
  6, 6,
  18, 18, 18, 18, 18, 18,
  10, 10, 10,
  10, 10, 10,
  3, 3, 3
};
void setup(void)
{
  pinMode(8, OUTPUT);//buzzer
  pinMode(13, OUTPUT);//led indicator when singing a note
}
void loop()
{
  //sing the tunes
  sing(1);
  sing(1);
  sing(2);
}
int song = 0;
void sing(int s) {
  // iterate over the notes of the melody:
  song = s;
  if (song == 2) {
    Serial.println(" 'Underworld Theme'");
    int size = sizeof(underworld_melody) / sizeof(int);
    for (int thisNote = 0; thisNote < size; thisNote++) {
      // to calculate the note duration, take one second
      // divided by the note type.
      //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
      int noteDuration = 1000 / underworld_tempo[thisNote];
      buzz(melodyPin, underworld_melody[thisNote], noteDuration);
      // to distinguish the notes, set a minimum time between them.
      // the note's duration + 30% seems to work well:
      int pauseBetweenNotes = noteDuration * 1.30;
      delay(pauseBetweenNotes);
      // stop the tone playing:
      buzz(melodyPin, 0, noteDuration);
    }
  } else {
    Serial.println(" 'Mario Theme'");
    int size = sizeof(melody) / sizeof(int);
    for (int thisNote = 0; thisNote < size; thisNote++) {
      // to calculate the note duration, take one second
      // divided by the note type.
      //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
      int noteDuration = 1000 / tempo[thisNote];
      buzz(melodyPin, melody[thisNote], noteDuration);
      // to distinguish the notes, set a minimum time between them.
      // the note's duration + 30% seems to work well:
      int pauseBetweenNotes = noteDuration * 1.30;
      delay(pauseBetweenNotes);
      // stop the tone playing:
      buzz(melodyPin, 0, noteDuration);
    }
  }
}
void buzz(int targetPin, long frequency, long length) {
  digitalWrite(13, HIGH);
  long delayValue = 1000000 / frequency / 2; // calculate the delay value between transitions
  //// 1 second's worth of microseconds, divided by the frequency, then split in half since
  //// there are two phases to each cycle
  long numCycles = frequency * length / 1000; // calculate the number of cycles for proper timing
  //// multiply frequency, which is really cycles per second, by the number of seconds to
  //// get the total number of cycles to produce
  for (long i = 0; i < numCycles; i++) { // for the calculated length of time...
    digitalWrite(targetPin, HIGH); // write the buzzer pin high to push out the diaphram
    delayMicroseconds(delayValue); // wait for the calculated delay value
    digitalWrite(targetPin, LOW); // write the buzzer pin low to pull back the diaphram
    delayMicroseconds(delayValue); // wait again or the calculated delay value
  }
  digitalWrite(13, LOW);
}


Video































14 Mart 2015 Cumartesi

Arduino Experiment 3 - RGB Modify

Definition : We change RGB Led's colour by using potentiometer. Changing resistor values gives different colours.

Circuit Diagram



Components

  •         1 x RGB LED
  •            1 x 10kΩ Resistor
  •            Arduino Uno
  •           Wires

Arduino Code
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.
 */

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 7;
int led2 = 6;
int led3 = 5;

// the setup routine runs once when you press reset:
void setup() {               
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);  
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(led2, HIGH);
  digitalWrite(led3, HIGH);
}

Video


13 Mart 2015 Cuma

Arduino Experiment 5 - Push Buttons Modify

Circuit Diagram

Definition : In here, we use 2 buttons and 3 function to blink our leds. If left button is pushed, the leds will blink like disco. If right button pushed we have ordered blinking(from left to right) and if both are pushed, three of leds blink at the same time.





Components


  •          5 x 1K resistors
  •          3 x LED
  •          2 x On / Off Buttons
  •          Wires
  •          Arduino Uno


Arduino Code

// First we'll set up constants for the pin numbers.
// This will make it easier to follow the code below.

const int button1Pin = 2;  // pushbutton 1 pin
const int button2Pin = 3;  // pushbutton 2 pin
const int ledPin =  13;    // LED pin
const int ledPin2 = 12;
const int ledPin3 = 11;


void setup()
{
  // Set up the pushbutton pins to be an input:
  pinMode(button1Pin, INPUT);
  pinMode(button2Pin, INPUT);

  // Set up the LED pin to be an output:
  pinMode(ledPin, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin2, OUTPUT);

}


void loop()
{
  int button1State, button2State;  // variables to hold the pushbutton states

  // Since a pushbutton has only two states (pushed or not pushed),
  // we've run them into digital inputs. To read an input, we'll
  // use the digitalRead() function. This function takes one
  // parameter, the pin number, and returns either HIGH (5V)
  // or LOW (GND).

  // Here we'll read the current pushbutton states into
  // two variables:

  button1State = digitalRead(button1Pin);
  button2State = digitalRead(button2Pin);

  if ((button1State == LOW)) {
    for(int i = 2; i>=1; i--) {
    digitalWrite(ledPin, HIGH);  // turn the LED on
    delay(500);
    digitalWrite(ledPin2, HIGH);  // turn the LED
    delay(500);
    digitalWrite(ledPin3, HIGH);  // turn the LED on
    delay(500);
    digitalWrite(ledPin, LOW);  // turn the LED on
    delay(500);
    digitalWrite(ledPin2, LOW);  // turn the LED on
    delay(500);
    digitalWrite(ledPin3, LOW);  // turn the LED on
    delay(500);
       }  
  }    

  if ((button1State == LOW) && (button2State == LOW))  // if we're pushing button 1 OR button 2
        {                                             // AND we're NOT
      // pushing button 1 AND button 2
                                                     // then...


    digitalWrite(ledPin, HIGH);  // turn the LED on
    digitalWrite(ledPin2, HIGH);  // turn the LED on
    digitalWrite(ledPin3, HIGH);  // turn the LED on
    delay(500);
    digitalWrite(ledPin, LOW);  // turn the LED on
    digitalWrite(ledPin2, LOW);  // turn the LED on
    digitalWrite(ledPin3, LOW);  // turn the LED on
    delay(500);
     digitalWrite(ledPin, HIGH);  // turn the LED on
    digitalWrite(ledPin2, HIGH);  // turn the LED on
    digitalWrite(ledPin3, HIGH);  // turn the LED on
    delay(500);
    digitalWrite(ledPin, LOW);  // turn the LED on
    digitalWrite(ledPin2, LOW);  // turn the LED on
    digitalWrite(ledPin3, LOW);  // turn the LED on
    delay(500);
     digitalWrite(ledPin, HIGH);  // turn the LED on
    digitalWrite(ledPin2, HIGH);  // turn the LED on
    digitalWrite(ledPin3, HIGH);  // turn the LED on
    delay(500);
    digitalWrite(ledPin, LOW);  // turn the LED on
    digitalWrite(ledPin2, LOW);  // turn the LED on
    digitalWrite(ledPin3, LOW);  // turn the LED on
  }
 
  if ((button2State == LOW)) {
    for(int i = 0; i<4; i++) {
    digitalWrite(ledPin, HIGH);  // turn the LED on
    digitalWrite(ledPin3, HIGH);  // turn the LED on
    delay(500);
    digitalWrite(ledPin2, HIGH);  // turn the LED on
 
    digitalWrite(ledPin, LOW);  // turn the LED on
    digitalWrite(ledPin3, LOW);  // turn the LED on
    delay(500);
    digitalWrite(ledPin2, LOW);  // turn the LED on
    }}}
  

Video : 

                                           

12 Mart 2015 Perşembe

Arduino Experiment 6 - Photo Resistor Modify

Definition : By using photo resistor, we can change the resistor value and send different amount of voltage to the leds base on our light level ! We arrange lightlevel value and give different values of each led so they react different to light as you see.

Circuit Diagram






























Components

  •          1 x Photo Resistor
  •          3 x Led ( Green, Yellow, Red)
  •          3 x 330 Ω Resistor
  •          Wires
  •          Uno Board


Code

const int sensorPin = 0;
const int ledPin = 9;
int ledPin2 = 10;
int ledPin3 = 11;

// We'll also set up some global variables for the light level:

int lightLevel, high = 0, low = 1023;


void setup()
{
  // We'll set up the LED pin to be an output.
  // (We don't need to do anything special to use the analog input.)

  pinMode(ledPin, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
}

void loop()
{
  lightLevel = analogRead(sensorPin);

  manualTune();  // manually change the range from light to dark

  analogWrite(ledPin, lightLevel);
  analogWrite(ledPin2, lightLevel+1);
  analogWrite(ledPin3, lightLevel+100);
}

void manualTune()
{
 
  lightLevel = map(lightLevel, 0, 10, 0, 255);
  lightLevel = constrain(lightLevel, 0, 255);
}
void autoTune()
{
  if (lightLevel < low)
  {
    low = lightLevel;
  }


  if (lightLevel > high)
  {
    high = lightLevel;
  }
  lightLevel = map(lightLevel, low+30, high-30, 0, 255);
  lightLevel = constrain(lightLevel, 0, 255);

 
}


Video