Difference between revisions of "Project adMIRE"

From RoboWiki
Jump to: navigation, search
m
(Project Files)
 
(14 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
== Overview ==
 
== Overview ==
  
[[Image:admIRE.jpg|thumb|adMIRE|200px|right|Design of the hover]]
+
[[Image:admIRE.jpg|thumb|adMIRE|200px|right|adMIRE]]
  
'''Author(s): ''' Adrian-Valentin MARINESCU/Mirela MOGA  <BR>
+
'''Authors: ''' Adrian-Valentin MARINESCU/Mirela MOGA  <BR>
'''Country(s): ''' Romania/Romania              <BR>
+
'''Countries: ''' Romania              <BR>
 
'''Date: ''' 11.07.2010                        <BR>
 
'''Date: ''' 11.07.2010                        <BR>
 
'''Activity: ''' R.U.R. - Summer School 2010  <BR>
 
'''Activity: ''' R.U.R. - Summer School 2010  <BR>
  
 
== Abstract ==
 
== Abstract ==
Welcome to adMIRE!
+
Welcome to '''adMIRE'''!
It can run and sing at the same time. When a black path crosses his way, he stops, then turns around and continues his journey. If he reaches the edge  of a clif, don't worry, he won't fall, he find the proper way to go :).
 
  
'''Hardware Design''': Our robot consists of a basic Boe-Bot to which we have attached a light senzor and a piezoelectric speaker.
+
It can run and sing at the same time. When a black path crosses his way, he stops, then turns around and continues his journey. If he reaches the edge  of a clif, don't worry, he won't fall, he will find the proper way to go :).  
  
'''Software Design''': There is a main loop on which the robot analises its current state and decides whether to stop, turn around or to move forward. We also have auxilliar functions for creating the sounds.
+
'''Hardware Design''': Our robot consists of a basic ACROBot to which we have attached a light sensor and a piezoelectric speaker.
 +
 
 +
'''Software Design''': There is a main loop on which the robot analizes its current state and decides whether to stop, turn around or to move forward. We also have auxiliar functions for creating the sounds.
 +
 
 +
'''Source code'''
 +
<source lang="c">
 +
#include <Servo.h>
 +
#define SerialSpeed 9600 
 +
#define SampFrequency 10 
 +
#define AnalogPIN 5 
 +
#define SENSOR_1    1
 +
 
 +
 
 +
Servo LeftServo; 
 +
Servo RightServo; 
 +
 
 +
 
 +
#define FAST  50 
 +
#define SLOW  5
 +
 
 +
 
 +
int speakerPin = 4;
 +
int length = 15;
 +
char notes[] = "ccggaagffeeddc ";
 +
int beats[] = { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 4 };
 +
int tempo = 300;
 +
 
 +
void playTone(int tone, int duration) {
 +
  for (long i = 0; i < duration * 1000L; i += tone * 2) {
 +
    digitalWrite(speakerPin, HIGH);
 +
    delayMicroseconds(tone);
 +
    digitalWrite(speakerPin, LOW);
 +
    delayMicroseconds(tone);
 +
    if(analogRead(SENSOR_1)>=750) return;
 +
  }
 +
}
 +
 
 +
void playNote(char note, int duration) {
 +
  char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
 +
  int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 };
 +
 
 +
 
 +
  for (int i = 0; i < 8; i++) {
 +
    if (names[i] == note) {
 +
      playTone(tones[i], duration);
 +
    }
 +
  }
 +
}
 +
 
 +
void setup() {
 +
  pinMode(speakerPin, OUTPUT);
 +
  Serial.begin(SerialSpeed);
 +
  LeftServo.attach(9);
 +
  RightServo.attach(10); 
 +
  LeftServo.write(90 + FAST); 
 +
  RightServo.write(90 - FAST); 
 +
}
 +
 
 +
void loop() {
 +
  for (int i = 0; i < length; i++) {
 +
    if (notes[i] == ' ') {
 +
      delay(beats[i] * tempo);
 +
    } else {
 +
      playNote(notes[i], beats[i] * tempo);
 +
    }
 +
 
 +
 
 +
//Serial.println( analogRead(AnalogPIN));
 +
if(analogRead(SENSOR_1)<750) 
 +
{ LeftServo.write(90 + FAST);   
 +
RightServo.write(90 - FAST);           
 +
}
 +
  else
 +
  {
 +
  LeftServo.write(90);         
 +
  RightServo.write(90);
 +
  delay(1500);
 +
  noTone(speakerPin);
 +
  LeftServo.write(90 - FAST);
 +
  RightServo.write(90 + FAST);
 +
  delay(1000);
 +
  LeftServo.write(90 + FAST); 
 +
  RightServo.write(90 + FAST);
 +
  delay(1000);
 +
  }
 +
}
 +
 +
</source>
  
 
== Project Files ==
 
== Project Files ==
Line 23: Line 109:
 
| Project documentation || [[Media:MyDocumentation.pdf]]
 
| Project documentation || [[Media:MyDocumentation.pdf]]
 
|-
 
|-
| Project sourcecode         || [[Media:admire.c]]
+
| Project source code         || [[Media:admire.c]]
 +
|-
 +
| Project movie         || [http://robotika.sk/holls/2010/video/admire.avi AdMire.avi] (17 MB)
 
|-
 
|-
 
|}
 
|}
Line 30: Line 118:
 
Go back to the [[Summer_School_2010#Projects|List of the projects]]
 
Go back to the [[Summer_School_2010#Projects|List of the projects]]
  
[[Category:Projects]]
+
[[Category:Projects]][[Category:Robotic_Summer_School_2010]]
  
 
__notoc__
 
__notoc__

Latest revision as of 10:59, 24 July 2010

Overview

adMIRE

Authors: Adrian-Valentin MARINESCU/Mirela MOGA
Countries: Romania
Date: 11.07.2010
Activity: R.U.R. - Summer School 2010

Abstract

Welcome to adMIRE!

It can run and sing at the same time. When a black path crosses his way, he stops, then turns around and continues his journey. If he reaches the edge of a clif, don't worry, he won't fall, he will find the proper way to go :).

Hardware Design: Our robot consists of a basic ACROBot to which we have attached a light sensor and a piezoelectric speaker.

Software Design: There is a main loop on which the robot analizes its current state and decides whether to stop, turn around or to move forward. We also have auxiliar functions for creating the sounds.

Source code

#include <Servo.h> 
#define SerialSpeed 9600   
#define SampFrequency 10  
#define AnalogPIN 5   
#define SENSOR_1     1


Servo LeftServo;   
Servo RightServo;  


#define FAST  50   
#define SLOW   5


int speakerPin = 4;
int length = 15; 
char notes[] = "ccggaagffeeddc "; 
int beats[] = { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 4 };
int tempo = 300;

void playTone(int tone, int duration) {
  for (long i = 0; i < duration * 1000L; i += tone * 2) {
    digitalWrite(speakerPin, HIGH);
    delayMicroseconds(tone);
    digitalWrite(speakerPin, LOW);
    delayMicroseconds(tone);
    if(analogRead(SENSOR_1)>=750) return; 
  }
}

void playNote(char note, int duration) {
  char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
  int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 };


  for (int i = 0; i < 8; i++) {
    if (names[i] == note) {
      playTone(tones[i], duration);
    }
  }
}

void setup() {
  pinMode(speakerPin, OUTPUT);
  Serial.begin(SerialSpeed);
  LeftServo.attach(9);
  RightServo.attach(10);  
  LeftServo.write(90 + FAST);  
  RightServo.write(90 - FAST);  
}

void loop() {
  for (int i = 0; i < length; i++) {
    if (notes[i] == ' ') {
      delay(beats[i] * tempo); 
    } else {
      playNote(notes[i], beats[i] * tempo);
    }
   
   
 //Serial.println( analogRead(AnalogPIN)); 
 if(analogRead(SENSOR_1)<750)  
 { LeftServo.write(90 + FAST);    
 RightServo.write(90 - FAST);            
 }
  else
  {
  LeftServo.write(90);           
  RightServo.write(90);
  delay(1500);
  noTone(speakerPin);
  LeftServo.write(90 - FAST);
  RightServo.write(90 + FAST);
  delay(1000);
  LeftServo.write(90 + FAST);   
  RightServo.write(90 + FAST);
  delay(1000);
  }
 }
}

Project Files

Description Download
Project documentation Media:MyDocumentation.pdf
Project source code Media:admire.c
Project movie AdMire.avi (17 MB)


Go back to the List of the projects