#include <conio.h>
#include <dbutton.h>
#include <dsensor.h>
#include <dmotor.h>
#include <dsound.h>
#include <sys/tm.h>
#include <rom/system.h>
#define NORMAL_SPEED (MAX_SPEED)
static const note_t melody[] = {
{PITCH_A4,1},{ PITCH_END, 0 }
};
//-------------------------------
int main()
{
int current1=0;
int current3=0;
int preced1=0;
ds_active(&SENSOR_3);
ds_active(&SENSOR_1);
//on ne se sert ici que de la partie emettrice de ce capteur
sleep(3);
//initialisation
while (1)
{
current1=LIGHT_1;
current3=LIGHT_3;
if (current3 <80){//black
motor_a_dir(fwd);
motor_c_dir(fwd);
motor_a_speed(NORMAL_SPEED);
motor_b_speed(NORMAL_SPEED);
motor_c_speed(NORMAL_SPEED);
}
else if ((current3 <110) && (current3>80)){//white
motor_a_dir(rev);
motor_c_dir(rev);
motor_a_speed(NORMAL_SPEED);
motor_b_speed(NORMAL_SPEED);
motor_c_speed(NORMAL_SPEED);
}
else {
msleep(7);
dsound_play(melody); //for debug...
motor_a_dir(brake);
motor_b_dir(brake);
motor_c_dir(brake);
}
msleep(7);
}
return 0;
}