29 Kasım 2016 Salı

Check out the link for the process of RomniBOT and Autonomous Vehicles of RAVLAB from Işık University. https://www.youtube.com/channel/UCwSeTw3fKw9U3Wsodt3I1NQ


      

      





      Transaction from Omni Directional Robot to RomniBOT. RomniBOT is a mobile robot which can construct the map of a floor of any building both autonomously and manually. 

10 Mayıs 2015 Pazar

Driving a Motor via a Soft Potentiometer and a Flex Sensor

        To drive the motor, a Soft Potentiometer, a Flex Sensor are used. The Soft Potentiometer is used to set the speed/pwm of the motor whereas the Flex Sensor is used to change the direction of the motor, either forward or bacward. There are two leds, RED is indicating that the motor is being drive FORWARD whereas GREEN is indicating BACKWARD.

        The circuit diagrams (one made on digital environment, the other one is the implemented) and the datasheet of shift register can be seen below:


Digital Drawed Circuit



Implemented Circuit


      Here is a video available to see the outputs and how the system works:





Arduino Code :


/*
  Can KAVALOĞLU
*/

int softPin = 0;
int flexPin = 1;
int motorPin = 9;
int redPin = 12;
int greenPin = 13;
int softValue, flexValue, motorPwm;

void setup(){
  pinMode(softPin, INPUT);
  pinMode(flexPin, INPUT);  
  pinMode(motorPin, OUTPUT);
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  Serial.begin(9600);
}

void loop(){
  softValue = analogRead(softPin);
  motorPwm = map(softValue, 0, 1023, 0, 255);
  flexValue = analogRead(flexPin);
  flexValue = constrain(flexValue, 710, 950);
  
  if(flexValue > 830){
    motorPwm *= -1;
    digitalWrite(redPin, HIGH);
    digitalWrite(greenPin, LOW);
  }
  else{
    digitalWrite(redPin, LOW);
    digitalWrite(greenPin, HIGH);  
  }
  analogWrite(motorPin, motorPwm);
  Serial.print("PWM : ");
  Serial.print(motorPwm);
  Serial.print(" direc: ");
  Serial.println(flexValue);
}


Buzzer Control by using a Soft Potentiometer

        Using a Soft Potentiometer, we are able to control the song of the buzzer that is being played. As the value of the Soft potentiometer changes, so as the note of the buzzer.

        The circuit diagrams (one made on digital environment, the other one is the implemented) and the datasheet of shift register can be seen below:


Digital Drawed Circuit



Implemented Circuit



      Here is a video available to see the outputs and how the system works:







Arduino Code :


/*
  Can KAVALOĞLU
*/

const int softPin = 0;
const int buzzerPin = 9;
const int songLength = 18;
char notes[] = "cdfda ag cdfdg gf ";
int beats[] = {1,1,1,1,1,1,4,4,2,1,1,1,1,1,1,4,4,2};
int tempo = 150;
char notes_2[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b' };

void setup(){
  pinMode(buzzerPin, OUTPUT);
  Serial.begin(9600);
}

void loop(){
  int i, duration,index;
  index = analogRead(softPin)/4; 
  index = map(index, 0, 256, 0, 6);
  
  duration = beats[i] * tempo;
  if (notes[i] == ' '){
    delay(duration);
  }
  else{
    tone(buzzerPin, frequency(notes_2[index]), duration);
    delay(duration);
  }
  delay(tempo/10);
  Serial.println(index);
}


int frequency(char note){
  int i;
  const int numNotes = 8;
  char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
  int frequencies[] = {262, 294, 330, 349, 392, 440, 494, 523};

  for (i = 0; i < numNotes; i++){
    if (names[i] == note){
      return(frequencies[i]);
    }
  }
  return(0);
}



Driving Servo Motor using Push Buttons and Potentiometer

        To drive the servo, two push buttons and a potentiotemers is being used. Push Buttons are for increasing/decreasing the speed/delayTime of the servo whereas the potentiometer is in charge to manipulate direction/location of the servo.

        The circuit diagrams (one made on digital environment, the other one is the implemented) and the datasheet of shift register can be seen below:


Digital Drawed Circuit



Implemented Circuit


      

Here is a video available to see the outputs and how the system works:





Arduino Code :


/*
  Can KAVALOĞLU
*/

#include <Servo.h> 
Servo myservo;

int potPin = 0;
int bttn1Pin = 10;
int bttn2Pin = 11;
int potValue, bttn1Value, bttn2Value, delayTime = 15;

void setup(){
    pinMode(potPin, INPUT);
    pinMode(bttn1Pin, INPUT);
    pinMode(bttn2Pin, INPUT);    
    myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
    Serial.begin(9600);
}

void loop(){
  bttn1Value = digitalRead(bttn1Pin);
  bttn2Value = digitalRead(bttn2Pin);
  potValue = analogRead(potPin);
  potValue = map(potValue, 0, 1023, 0, 180);
  
  if(bttn1Value == HIGH && bttn2Value == LOW){
      if(delayTime > 5)
        delayTime -= 5;
  }
  else if(bttn1Value == LOW && bttn2Value == HIGH){
        delayTime += 5;
  }
  
  myservo.write(potValue);
  Serial.println(potValue);
  delay(delayTime);
}


Driving multiple leds via Flex Sensor

        There are three leds that are composed of a green, a yellow and a red led (like a traffic lamb). The flex sensor provides us to be able to switch between these three leds and ligth one of them at a time.

        The circuit diagrams (one made on digital environment, the other one is the implemented) and the datasheet of shift register can be seen below:


Digital Drawed Circuit


Implemented Circuit



      Here is a video available to see the outputs and how the system works:





Arduino Code :

/*
    Can KAVALOĞLU
 */
int greenPin = 8;
int yellowPin = 9;
int redPin = 10;
int flexValue;

void setup(){
    pinMode(flexPin, INPUT);
    pinMode(greenPin, OUTPUT);
    pinMode(yellowPin, OUTPUT);
    pinMode(redPin, OUTPUT);    
    Serial.begin(9600);
}

void loop(){
  flexValue = analogRead(flexPin);
  flexValue = constrain(flexValue, 720, 950);
  flexValue = map(flexValue, 720, 950, 0, 1024);
  if(flexValue < 350){
    digitalWrite(greenPin, HIGH);
    digitalWrite(yellowPin, LOW);
    digitalWrite(redPin, LOW);  
  }
  else if(flexValue < 600){
    digitalWrite(greenPin, LOW);
    digitalWrite(yellowPin, HIGH);
    digitalWrite(redPin, LOW);  
  }
  else{
    digitalWrite(greenPin, LOW);
    digitalWrite(yellowPin, LOW);
    digitalWrite(redPin, HIGH);  
  }
  Serial.println(flexValue);  
  delay(200);
}

RGB Led control via Push Buttons

        There are two push buttons, one for switching between red-green-blue colors where the other buttons is used to control the brightness of the color that is currently alight.

        When both buttons are pressed at the same time, the RGB led goes off and no color can be seen.

        The circuit diagrams (one made on digital environment, the other one is the implemented) and the datasheet of shift register can be seen below:


Digital Drawed Circuit


Implemented Circuit

 

      Here is a video available to see the outputs and how the system works:




Arduino Code :

/*
  Can KAVALOĞLU
*/

int bttnPin1 = 6;
int bttnPin2 = 7;
int LEDRed = 9;
int LEDGreen = 10;
int LEDBlue = 11;
int bttnValue1, bttnValue2;
int count = 0;
int pwm_value = 255;
 
void setup(){
  pinMode(LEDRed, OUTPUT);
  pinMode(LEDGreen, OUTPUT);
  pinMode(LEDBlue, OUTPUT);
  pinMode(bttnPin1, INPUT);
  pinMode(bttnPin2, INPUT);
  Serial.begin(9600);
}
 
void loop(){
  bttnValue1 = digitalRead(bttnPin1);
  bttnValue2 = digitalRead(bttnPin2);
  Serial.print("Button 1 : ");
  Serial.print(bttnValue1);
  Serial.print(" Button 2 : ");
  Serial.println(bttnValue2);
  if(bttnValue1 == HIGH && bttnValue2 == LOW){
      pwm_value = pwm_value - 20;
      if(count == 0){
      analogWrite(LEDRed, pwm_value);
      analogWrite(LEDBlue,0); 
      analogWrite(LEDGreen,0);
    }
    else if(count == 1){
      analogWrite(LEDRed, 0);
      analogWrite(LEDBlue,0); 
      analogWrite(LEDGreen,pwm_value);
    }
    else if(count == 2){
      analogWrite(LEDRed, 0);
      analogWrite(LEDBlue,pwm_value); 
      analogWrite(LEDGreen,0);
    }   
   delay(100); 
  }
      
  else if(bttnValue2 == HIGH && bttnValue1 == LOW){
    count++;
    count = count % 3;
    if(count == 0){
      analogWrite(LEDRed, pwm_value);
      analogWrite(LEDBlue,0); 
      analogWrite(LEDGreen,0);
    }
    else if(count == 1){
      analogWrite(LEDRed, 0);
      analogWrite(LEDBlue,0); 
      analogWrite(LEDGreen,pwm_value);
    }
    else if(count == 2){
      analogWrite(LEDRed, 0);
      analogWrite(LEDBlue,pwm_value); 
      analogWrite(LEDGreen,0);
    }    
    delay(100);
  }
  else if(bttnValue1 == HIGH && bttnValue2 == HIGH){
    analogWrite(LEDRed, 0);
    analogWrite(LEDBlue,0); 
    analogWrite(LEDGreen,0);
  }   
}