Ejemplo n.º 1
0
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();
}
Ejemplo n.º 2
0
JNIEXPORT void JNICALL Java_org_nzdis_example03_GLESView_myStartSensors
  (JNIEnv *, jclass)
{
	SENSORS_ENABLED = 1;
	setup_sensors();
}