// programa completo.c - Criado pelo studio UNO 2.3
// 3 November 2016 6:46:31 pm
#include <uno.h>
// Prototipos
void bumper(void);
void curvas(void);
//Funcoes do Usuario
void bumper(void)
{
if ((!__digital_in(5) || !__digital_in(6))) {
__motor_curso(__STOP);
__lcd_clear();
__lcd_goto(0x7f, 5);
__lcd_puts("Objetinho");
__beep();
__motor_curso(__BACKWARD);
__lcd_goto(0xbf, 5);
__lcd_puts("Voltando");
for (int __i1 = 0; __i1 < 6; ++__i1) {
__buzzer(58, 300);
__delay(300);
}
__motor_curso(__STOP);
__lcd_clear();
__lcd_goto(0x7f, 6);
__lcd_puts("Parei");
}
}
void curvas(void)
{
if (!testbit(__IR, 6)) {
if (!testbit(__IR, 1)) {
__motor_curso(__LEFT_ROTATE);
__lcd_clear();
__lcd_goto(0x7f, 6);
__lcd_puts("Rodando E");
}
if (!testbit(__IR, 3)) {
__motor_curso(__RIGHT_ROTATE);
__lcd_clear();
__lcd_goto(0x7f, 6);
__lcd_puts("Rodando D");
}
}
else {
if ((!testbit(__IR, 1) || __LEFT_KEY)) {
__motor_curso(__LEFT_TURN);
__lcd_clear();
__lcd_goto(0x7f, 6);
__lcd_puts("Curvinha E");
}
if ((!testbit(__IR, 3) || __RIGHT_KEY)) {
__motor_curso(__RIGHT_TURN);
__lcd_clear();
__lcd_goto(0x7f, 6);
__lcd_puts("Curvinha D");
}
}
}
//Funcao Principal
void main(void)
{
__inicializa;
__IR__ON();
__backlight(__ON);
__lcd_goto(0x7f, 6);
__lcd_puts("To parado");
while(TRUE) {
if ((!testbit(__IR, 0) || __UP_KEY)) {
__motor_curso(__FORWARD);
__lcd_clear();
__lcd_goto(0x7f, 6);
__lcd_puts("Frente");
}
if ((!testbit(__IR, 4) || __BOTTOM_KEY)) {
__motor_curso(__BACKWARD);
__lcd_clear();
__lcd_goto(0x7f, 6);
__lcd_puts("UNO");
}
if ((!testbit(__IR, 2) || __ENTER_KEY)) {
__motor_curso(__STOP);
__lcd_clear();
__lcd_goto(0x7f, 6);
__lcd_puts("Parei");
}
curvas();
bumper();
}
while(TRUE) { }
}