Esempio n. 1
0
int follow_wall(bool(*cond)(void)) {
	unsigned long ADCValue = getADCValue();
	int speed = 127;
	if((*cond)()) return COND_BREAK;
	if (wallApproach()) return CORNER;
	if(ADCValue > 500)
	{
		if(ADCValue > 600)
		{
			SetMotorPowers (-speed, speed);
		}
		else
			SetMotorPowers(speed/3, speed);
		UARTprintf("IR value1: %d\r",ADCValue);
	}
	//adj = (600 - ADCValue)/10;
	//rotate (adj);
	else if(ADCValue < 300)
	{
		if(ADCValue < 150)
		{
			SetMotorPowers(speed, -50);
		}
		else
			SetMotorPowers(speed, speed/3);
		UARTprintf("\nIR value2: %d\r",ADCValue);
	}
	return RETURN_W;
}
Esempio n. 2
0
void IRSensorDemo(void) {
	UARTprintf("Press:\nany key-read IR sensor\n");
	UARTprintf("any key after read begins-quit\n");
	
	while(!keyWasPressed()) {
		unsigned long ADCValue = getADCValue();
	 	UARTprintf("IR value: %d\r",ADCValue);
	}	
	UARTprintf("\n");
}
Esempio n. 3
0
void main(void) {
	/* your definitions here */
	int lVal, rVal;
	
	// init buttons and seven-segment displays
	initIO();
	// init A/D converter
	initADC();
	
	/* your code here */
	for (;;) {
		// read AN1...
		lVal = getADCValue(1) * 3 / 85;
		// read AN2...
		rVal = getADCValue(2) * 3 / 85;
		setLeft7Seg(lVal);
		setRight7Seg(rVal);
	}
}
Esempio n. 4
0
int main (void)
{
    // Inicializamos la placa
    initBoard();
    
    // Bucle infinito
    while(1)
    {
        barraLed(getADCValue());
    }
    
    return 0;
}
Esempio n. 5
0
void loop() {
	while(1){
		sendString(Time, Latitude, Longitude, Altitude, internalTemp, externalTemp, NumSatalites, pressure, geigerCount, ADCValue[0]);
		getADCValue(0);
		getTemperature();
		readBMP085();
		readGeigerCount();
		//printf("UV: %i Temp: %F Lat: %F Long: %F Alt: %F SatNu: %i Pressure %i iTemp %F GMC: %i\n", ADCValue[0], externalTemp, Latitude, Longitude, Altitude, NumSatalites, pressure, internalTemp, geigerCount);
		closeRadio();
		getGPS();
		//sleep(1);
	}
}
Esempio n. 6
0
File: Main.c Progetto: 88Fuzz/Drums
int main(void)
{
    SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
    initialize();
    uint16_t adcValue = 0;
    uint16_t prevAdcValue = 0;

    while(1)
    {   
        SysCtlDelay(1500);
        adcValue = getADCValue(0x0);
        int32_t adcDiff = adcValue - prevAdcValue;
        volumeLights(adcDiff);
        prevAdcValue = adcValue;
    }   
}
Esempio n. 7
0
void main(void) {
	/* your definitions here */
  int leftADValue = 0;
  int rightADValue = 0;
  char leftButton = 1;
  char leftButtonLast = 1;
  char rightButton = 1;
  char rightButtonLast = 1;
	
	// init buttons and seven-segment displays
	initIO();
	// init LCD
	initLCD();
	// init A/D converter
	initADC();

	
	/* your code here */
  drawBuffer();
  wait(100001);
  //setPixel(10, 10, 1);

  //writeString(5, 0, "Hallo Welt");
  writeText(LOREM);

  for(;;) {
    switch (curMode) {
      case 0:
        leftADValue = getADCValue(1);
        curLine = inverseScaleDown(leftADValue, lines);
        writeInt(7, 0, curLine+1);
        writeInt(7, 104, lines);
        copyBuffer(curLine, 7);
        drawBuffer();
    //eventloop(4);
      break;
      case 1:
        copyBuffer(curLine, 7);
        writeInt(7, 0, curLine+1);
        writeInt(7, (128 - 4*CHARACTER_WIDTH), lines);
        drawBuffer();
        curLine++;
        if(curLine > lines)
          curMode = 6;
        else
          curMode = 2;
      break;
      case 2:
        wait(DELAY/2);
        curMode = 3;
      break;
      case 3:
        wait(DELAY/2);
        curMode = 4;
      break;
      case 4:
        wait(DELAY/2);
        curMode = 5;
      break;
      case 5:
        wait(DELAY/2);
        curMode = 1;
      break;
      case 6:
        __wait_nop();
      break;
    }
  printNumber(curMode);
  leftButton = PDR07_P0;
  rightButton = PDR07_P2;
  if(leftButton == 1 && leftButtonLast == 0) {
    if (curMode == 0) {
      curLine = 0;
      curMode = 1;
    }
    else {
      curMode = 0;

    }
  }
  leftButtonLast = leftButton;
  rightButtonLast = rightButton;
		__wait_nop();
  }
}