void setup() { //Wire.begin(); setup_led_pins(); setup_ports_for_movement(); setup_buzzer_pin(); setup_sensors(); setup_smart_car_control_logic(); int z; // ToDo : Add a feature to make this happen from the android app. !!! // For this script, these values need to be entered manually. // InfraRed Sensor Value on black. int dac_val_min[8] = {101, 132, 109, 107, 137, 163, 119, 67}; // InfraRed Sensor Value on white. int dac_val_max[8] = {393, 571, 503, 514, 642, 616, 480, 358}; pinMode(IN_SEN_EN,OUTPUT); pinMode(S_DIN,OUTPUT); pinMode(S_SCLK,OUTPUT); pinMode(S_SYNCN,OUTPUT); digitalWrite(S_SCLK,LOW); digitalWrite(S_SYNCN,HIGH); digitalWrite(IN_SEN_EN,HIGH); /* These two for loops should be commented out initially and then after reading a sensor reading from a white input and a black input and inserting the values into dac_val_min[] and dac_val_max[] they should be uncommented. */ for (z=0; z<8; z++) { pinMode(SensorD[z], INPUT); } DAC_setting(0x9000); //for Write-Through Mode for (z=0; z<8; z++) { int mean_val = (dac_val_min[z]+dac_val_max[z])/2; //10-bit DAC_CH_Write(z, mean_val >> 2); //should be 8-bit } buzz_ready(); }
int main() { setup_led_pins(); // current color volatile rgb_t pwm; // next color volatile rgb_t color; // enable random number generator RNG_SHORTS = RNG_SHORTCUT_VALRDY_STOP; RNG_START = 1; while(true) { // fade towards color while (color.red != pwm.red || color.green != pwm.green || color.blue != pwm.blue) { PWM(&pwm); // for (uint8_t i=0; i<1; i++) // { if (color.red > pwm.red) pwm.red++; if (color.red < pwm.red) pwm.red--; if (color.green > pwm.green) pwm.green++; if (color.green < pwm.green) pwm.green--; if (color.blue > pwm.blue) pwm.blue++; if (color.blue < pwm.blue) pwm.blue--; // } } // display this color for a while for (uint8_t i=0; i<100; i++) PWM(&color); // choose new, random color color.red = random(); color.green = random(); color.blue = random(); } return 0; }
int main() { setup_led_pins(); while(true) { off(PIN_LED_WHITE_2); on(PIN_LED_RED_BRIGHT); delay_ms(1000); off(PIN_LED_RED_BRIGHT); on(PIN_LED_GREEN); delay_ms(1000); off(PIN_LED_GREEN); on(PIN_LED_YELLOW_1); delay_ms(1000); off(PIN_LED_YELLOW_1); on(PIN_LED_WHITE_1); delay_ms(1000); off(PIN_LED_WHITE_1); on(PIN_LED_YELLOW_2); delay_ms(1000); off(PIN_LED_YELLOW_2); on(PIN_LED_BLUE); delay_ms(1000); off(PIN_LED_BLUE); on(PIN_LED_RED); delay_ms(1000); off(PIN_LED_RED); on(PIN_LED_WHITE_2); delay_ms(1000); } return 0; }