Exemplo n.º 1
0
int main(void)
{
	char serialCharacter;
	
	lcd_init(LCD_DISP_ON);
	lcd_gotoxy(2,0); lcd_puts("Serial");
	lcd_gotoxy(3,1); lcd_puts("LCD");
	
	DDRD |= (1<<PD1);	// habilita o pino PD1 como TXD (output)
	DDRB |= (1<<PB0);	// habilita o LED no pino PB0
	
	PORTB|=(1<<PB0);
	
	initUSART();
	printString("Serial ok:");
	
	PORTB&=~(1<<PB0);
	
    while(1)
    {	PORTB|=(1<<PB0);
        serialCharacter = receiveByte();
		PORTB&=~(1<<PB0);
		lcd_putc(serialCharacter);
    }
}
int main(void) {

  char myString[STRING_MAXLEN];
  char *eepromAddress = (char *) STRING_ADDRESS;
  uint16_t counter;

  initUSART();

  while (1) {
    // Read from EEPROM and print out
    eeprom_read_block(myString, eepromAddress, STRING_MAXLEN);
    counter = eeprom_read_word((uint16_t *) COUNTER_ADDRESS);
    printString("\r\nYour old favorite color is: ");
    printString(myString);

    // Take input, store in EEPROM
    printString("\r\n\r\n Type your new favorite color.  ");
    readString(myString, sizeof(myString));
                   /* pass by address, function will change its values */
    eeprom_update_block(myString, eepromAddress, STRING_MAXLEN);
    counter++;
    printString("Thanks! \r\nYou've answered the same question ");
    printWord(counter);
    printString(" times.  \r\n");
    eeprom_update_word((uint16_t *) COUNTER_ADDRESS, counter);
  }

  return 0;
}
Exemplo n.º 3
0
/*
void Startdu2(unsigned portBASE_TYPE Priority)
{
	xTaskCreate(du2Task, (signed portCHAR *)"du2Task", configMINIMAL_STACK_SIZE, NULL, Priority, NULL );
}

void Startud2(unsigned portBASE_TYPE Priority)
{
	xTaskCreate(ud2Task, (signed portCHAR *)"ud2Task", configMINIMAL_STACK_SIZE, NULL, Priority, NULL );
}
 */
int main(void) 
{ 
   DDRC = 0xFF; PORTC = 0x00;
   DDRB = 0xF0; PORTB = 0x0F;
   
   
   //Initialize components and registers
   ADC_init();
   photoValueL = calibrate(0x02) - 4;
   photoValueR = calibrate(0x04) - 4;
   photoValueD = calibrate(0x01) - 4;
   photoValueU = calibrate(0x00) - 4;
   //photoValueD2 = calibrate(0x06) - 4;
   //photoValueU2 = calibrate(0x05) - 4;
   initUSART(1);
   
   //Start Tasks  
   keyPulse(1);
   Startlr(1);
   Startrl(1);
   Startdu(1);
   Startud(1);
   //Startdu2(1);
   //Startud2(1);
	//RunSchedular 
   vTaskStartScheduler(); 
 
   return 0; 
}
Exemplo n.º 4
0
int main(void)
{
	DDRD = (1<<1);		// habilita output no pino PD1 (TXD)
	DDRB = (1<<PB0);	// LED na porta PB0
	DDRB = (1<<PB5);	// habilita LED usado no bootloader 
						// (para piscar em status)
	
	char serialCharacter;
	
	LED_DDR=0xff;
	
	initUSART();
	PORTB |= (1<<PB0);
	PORTB &= ~(1<<PB5);
	printString("Ola Mundo\r\n");
	
	
    while(1)
    {
		serialCharacter = receiveByte();
		PORTB ^= _BV(PB0);
		transmitByte(serialCharacter);
		
		//LED_PORT=serialCharacter;
		PORTB ^= _BV(PB5);
		
	}
	
	return(0);
}
Exemplo n.º 5
0
Arquivo: main.c Projeto: icblnk/avr
void main()
{
    // Pin to measure impulse time
    //DDRB |= (0 << PINB0);
    //PORTB = (0 << PINB0);
    // LED pin
    DDRD |= (1 << PIND7);
    PORTD |= (0 << PIND7);

    // Trig pin
    PORTD |= (1 << PIND6);
    DDRD |= (1 << PIND6);

    blinkLed(5);
    initUSART();
    initTimer();

    USART_print("Main started\n");

    while(1) {
        PORTD |= 1 << PIND6;
        _delay_us(12);
        PORTD &= ~(1 << PIND6);
        _delay_ms(2000);
    }
}
Exemplo n.º 6
0
int main(void) {
  // -------- Inits --------- //
  clock_prescale_set(clock_div_1);                  /* CPU clock 8 MHz */
  initUSART();
  _delay_ms(1000);
  initTimer();
  DDRB = (1 << PB0) | (1 << PB1) | (1 << PB2) | (1 << PB3);

  // ------ Event loop ------ //
  while (1) {

                         /* Smooth movements, trapezoidal acceleration */
    trapezoidMove(2 * TURN);                         /* two full turns */
    trapezoidMove(-TURN / 2);                             /* half turn */
    trapezoidMove(TURN / 4);                           /* quarter turn */
    trapezoidMove(-TURN / 8);                                /* eighth */
    _delay_ms(TURN);
    trapezoidMove(-TURN / 4);                         /* the other way */
    trapezoidMove(TURN / 8);
    trapezoidMove(TURN / 2);                /* half turn back to start */
    _delay_ms(1000);

  }                                                  /* End event loop */
  return (0);                            /* This line is never reached */
}
int main(void)
{
  // Single character for serial TX/RX
  char a;

  // Enable output on all 8 bits in DDRB (but only PB0 and PB1 are used)
  DDRB = 0xff;

  // Enable pin change interrupt for the B pins, but only check PB0 and PB1.
  sei();
  PCICR |= (1 << PCIE0);
  PCMSK0 |= ((1 << PB0) | (1 << PB1));

  init_timer1();
  initUSART();

  pb[0] = PB0;
  pb[1] = PB1;
  while (1)
  {

    // for (uint8_t i=0; i<255; i++)
    //   cmd[i] = 0;

    // char cmd[255];
    // readString(cmd, 255);

    // if (strcmp(cmd, "V0_ON") == 0)
    // {
    //   printString("\r\nYou wrote: ");
    //   printString(cmd);
    //   printString("\r\n");
    //   PORTB |= (1 << PB0);
    // }

    // if (strcmp(cmd, "V1_ON"))
    //   PORTB |= (1 << PB1);
    // if (strcmp(cmd, "V0_OFF"))
    //   PORTB &= ~(1 << PB0);
    // if (strcmp(cmd, "V1_OFF"))
    //   PORTB &= ~(1 << PB1);

    // if (cmd == "V0_ON") set_bit(PORTB, PB0);
    // PORTB |= (1 << PB0);
    a = receiveByte();
    transmitByte(a);

    if (a == '0')
      PORTB &= ~(1 << PB0);
    if (a == '1')
      PORTB |= (1 << PB0);
    if (a == '2')
      PORTB &= ~(1 << PB1);
    if (a == '3')
      PORTB |= (1 << PB1);

    // PORTB = a;
  }
  return 0;
}
Exemplo n.º 8
0
int main(void) {

  initUSART();
  char ramString[STRING_LEN];
  uint8_t counter;

  while (1) {
    printString("\r\n------------------\r\n");
    eeprom_read_block(ramString, eepromString, STRING_LEN);
    printString(ramString);

    printString("\r\nThe counter reads: ");
    counter = eeprom_read_byte(&eepromCounter);
    printByte(counter);

    printString("\r\nMy uint16_t value is: ");
    printWord(eeprom_read_word(&eepromWord));

    printString("\r\n   Enter a new introduction string below:\r\n");
    readString(ramString, STRING_LEN);
    eeprom_update_block(ramString, eepromString, STRING_LEN);
    counter++;
    eeprom_update_byte(&eepromCounter, counter);
  }
  return (0);
}
int main(void) {
  initUSART();

  uint8_t myArray[] = { 10, 11, 12 };
  uint8_t *p;
  uint8_t i;
  p = &myArray[0];
  for (i = 0; i < sizeof(myArray); i++) {
    printByte(*(p + i));
    printString("\r\n");
    _delay_ms(1000);
  }


                                                       /* To use them: */
  char *stringPointer;
                /* Get the pointer to the string you want from PROGMEM */

  stringPointer = (char *) pgm_read_word(&stringIndex[0]);
  printString_Progmem(stringPointer);
                                                                 /* or */
  stringPointer = (char *) pgm_read_word(&stringIndex[1]);
  printString_Progmem(&stringPointer[0]);
                                                                 /* or */
  printString_Progmem(PSTR("And this string got inlined.\r\n"));

  while (1) {
    printData_Progmem(myData, sizeof(myData) / sizeof(myData[0]));
    printString("\r\n");
    _delay_ms(1000);
  }                                                  /* End event loop */
  return 0;                            /* This line is never reached */
}
Exemplo n.º 10
0
int main(void) 
{
    //-----------INITS------------//

    DDRB |= 0x01;
    PORTB = 0x00;
    initUSART();

    PORTB = 0x01;
    _delay_ms(100);
    PORTB = 0x00;
    _delay_ms(100);
    PORTB = 0x01;
    _delay_ms(1000);
    PORTB = 0x00;

    //-------EVENT LOOP-----------//
    while(1) 
    {  
        
        char in = receiveByte();
        /*
        if (in == 'h')
            PORTB = 0x01;
        else if (in == 'l')
            PORTB = 0x00;
        */
        PORTB = 0x01;
        for (int i=0; i<in; i++)
            _delay_ms(1);
        PORTB = 0x00;
    }
    return(0);

}
Exemplo n.º 11
0
int main(void)
{
	//---- PORT Initializations -----
	DDRB = 0xFF; PORTB = 0x00;
	DDRA = 0x00; PORTA = 0xFF;
	DDRC = 0xFF; PORTC = 0x00; //used for LCD display
	DDRD = 0xFF; PORTD = 0x00; //used for LCD display
	
	// --- Function Initializations ---
	TimerSet(5);
	TimerOn();
	PWM_on();
	initUSART();
	setCustomCharacters();
	LCD_init();

	//---if eeprom address was not initialized----
	if(eeprom_read_byte((uint8_t*)46) == 0xFF)
		eeprom_write_byte((uint8_t*)46 , 0);
		
	//----load old high score saved in EEPROM----
	currHighScore = eeprom_read_byte((uint8_t*)46);
	
	gameStatus = 0;
	soundStatus = 0;
	lcdTick();
	
	while(1){	
		mainTick();
		playSound();
		while(!TimerFlag);
		TimerFlag = 0;
	}
}
Exemplo n.º 12
0
int main(void) {

  float voltage;

  // -------- Inits --------- //
  initUSART();
  printString("\r\nDigital Voltmeter\r\n\r\n");
  initADC();
  setupADCSleepmode();

  // ------ Event loop ------ //

  while (1) {

    voltage = oversample16x() * VOLTAGE_DIV_FACTOR * REF_VCC / 4096;
    printFloat(voltage);
    /*  alternatively, just print it out:
     *  printWord(voltage*100);
     *  but then you have to remember the decimal place
     */
    _delay_ms(500);

  }                                                  /* End event loop */
  return 0;                            /* This line is never reached */
}
Exemplo n.º 13
0
int main(void) {
  // -------- Inits --------- //
  clock_prescale_set(clock_div_1);                       /* full speed */
  initUSART();
  printString("==[ Cap Sensor ]==\r\n\r\n");

  LED_DDR = 0xff;
  MCUCR |= (1 << PUD);                          /* disable all pullups */
  CAP_SENSOR_PORT |= (1 << CAP_SENSOR);    /* we can leave output high */

  initPinChangeInterrupt();

  // ------ Event loop ------ //
  while (1) {

    chargeCycleCount = 0;                             /* reset counter */
    CAP_SENSOR_DDR |= (1 << CAP_SENSOR);     /* start with cap charged */
    sei();                            /* start up interrupts, counting */
    _delay_ms(SENSE_TIME);
    cli();                                                     /* done */
    if (chargeCycleCount < THRESHOLD) {
      LED_PORT = 0xff;
    }
    else {
      LED_PORT = 0;
    }
    printWord(chargeCycleCount);                    /* for fine tuning */
    printString("\r\n");

  }                                                  /* End event loop */
  return (0);                            /* This line is never reached */
}
Exemplo n.º 14
0
int main(void) {

  // -------- Inits --------- //
  clock_prescale_set(clock_div_1);                  /* CPU clock 8 MHz */
  initUSART();
  printString("\r\nWelcome to the Servo Sundial.\r\n");
  printString("Type S to set time.\r\n");

  initTimer0_Clock();
  initTimer1_Servo();
  sei();                                   /* set enable interrupt bit */
  LED_DDR |= (1 << LED0);                             /* blinky output */
  LASER_DDR |= (1 << LASER);                    /* enable laser output */

  // ------ Event loop ------ //
  while (1) {

                                                 /* Poll clock routine */
    if (ticks == OVERFLOWS_PER_SECOND) {
      ticks = 0;
      everySecond();
    }

    pollSerial();

  }                                                  /* End event loop */
  return (0);                            /* This line is never reached */
}
Exemplo n.º 15
0
int main( void )
{
	uint16_t leftLightSensor = 0;
	uint16_t rightLightSensor = 0;
	char buffer0[5];
	char buffer1[5];

	initUSART();

	initADC();

	initPWM();

	while ( 1 )
	{
		/* Start ADC7 conversion */
		leftLightSensor = readADC( 7 );

		/* Convert 10-bit uint16_t adcValue to ASCII and store in buffer */
		itoa( leftLightSensor, buffer0, 10 );

		/* Print out leftLightSensor ADC Value */
		printString( "ADC Channel 6 (Left CD Sensor): " );
		printString( buffer0 );
		printString( "\n\n" );

		/* Start ADC6 conversion */
		rightLightSensor = readADC( 6 );

		/* Convert 10-bit uint16_t adcValue to ASCII and store in buffer */
		itoa( rightLightSensor, buffer1, 10 );

		/* Print out rightLightSensor ADC Value */
		printString( "ADC Channel 7 (Right CD Sensor): " );
		printString( buffer1 );
		printString( "\n\n" );

		/* Arch right if rightLightSensor reading is greater than leftLightSensor */
		if ( ( rightLightSensor - 100 ) > leftLightSensor )
		{
			leftwheel( 55, 1 );
			rightwheel( 35 , 1 );
		}
		/* Arch left if leftLightSensor reading is greater than rightLightSensor */
		else if ( ( leftLightSensor - 100 ) > rightLightSensor )
		{
			leftwheel( 35 , 1 );
			rightwheel( 45, 1 );
		}
		/* Go forward if both light sensors have the same reading */
		else
		{
			leftwheel( 35 , 1 );
			rightwheel( 35 , 1 );
		}
		_delay_ms( 500 );
	}
}
Exemplo n.º 16
0
int main(void) {
  initUSART();
  while (1) {
    printString_Progmem(&myVeryLongString1[0]);
    printString_Progmem(&myVeryLongString1[50]);
    printString_Progmem(myVeryLongString2);
    _delay_ms(1000);
  }                                                  /* End event loop */
  return (0);                            /* This line is never reached */
}
Exemplo n.º 17
0
void usartPrint_base(uint8_t c)
{
    if (cFlag == 0)
    {
        initUSART();
    }
    while ((UCSR0A & (1 << UDRE0)) == 0)
        ;
    UDR0 = c;
}
int main(void)
{
	DDRA = 0xFF;	PORTA = 0x00;
	DDRB = 0xF0;	PORTB = 0x0F;
	DDRC = 0xFF;	PORTC = 0x00;
	DDRD = 0x00;	PORTD = 0xFF;
	initUSART(0);
	initUSART(1);
	LCD_init();
	tasks[0].state = controllerinit;
	tasks[0].period = 1;
	tasks[0].elapsedTime = 1;
	tasks[0].TickFct = &TickFct_Controller;
	
	tasks[1].state = bluetoothWait;
	tasks[1].period = 5;
	tasks[1].elapsedTime = 5;
	tasks[1].TickFct = &TickFct_BluetoothReceiver;
	
	tasks[2].state = keypadWait1;
	tasks[2].period = 10;
	tasks[2].elapsedTime = 10;
	tasks[2].TickFct = &TickFct_KeypadReceiver;
	
	tasks[3].state = checkInit;
	tasks[3].period = 15;
	tasks[3].elapsedTime = 15;
	tasks[3].TickFct = &TickFct_CheckPin;
	
	tasks[4].state = usartInit;
	tasks[4].period = 5;
	tasks[4].elapsedTime = 5;
	tasks[4].TickFct = &TickFct_USART;
	
	TimerSet(1);
	TimerOn();
	while(1)
    {
    }
}
Exemplo n.º 19
0
void initALL()
{
	int flag;
				/*initialize the clocks and basic peripherals*/
   RCC_SYSCLKConfig(RCC_SYSCLKSource_HSE);		//set the SYSCLOCK
   RCC_HCLKConfig(RCC_SYSCLK_Div1);				//set the SYSCLOCK
   initUSART(USART1); 							//Initialize USART1
   //initUSART(USART3); 							//Initialize USART3
   ADC_Initialize();							//Initialize ADCs
   I2C_LowLevel_Init(I2C1, 100000, 0);			//Initialize I2C1 bus @ 100Khz speed
   I2C_LowLevel_Init(I2C2, 100000, 0);			//Initialize I2C1 bus @ 100Khz speed
   initLED();	         						//Initialize LEDs D3 D4
   initGPIO();									//initialize PB2 and PB12 used as external GPIO
   //InitTimer();  									//Initialize Timer

   	   	 /* Initialize and configure RF related functions */
   initRFconfpin();	// Init the GPIO PB15 used as CONFIG PIN with the RADIOCRAFT module


   //Configure the RF BOARD to standard value (configfile.c): NETID 2.2.2.2 Channel 2
   if (readintvalue(FLAG_EEPROM)!=0xf0f0f0f0){ //flag eeprom = f0f0f0f0 only when already initialized
   	   flag= ConfigureRF();
	   close_RFconfig();
	   if (flag==ERROR)
	   	   printf("Configuration Failed");
	   else
		   printf("Configuration RF ok");
   }
   else
	   close_RFconfig();

   	  /* Initialize EEPROM VALUES*/
   if (readintvalue(FLAG_EEPROM)!=0xf0f0f0f0){   //flag eeprom = f0f0f0f0 only when already initialized
	   init_eeprom(); //Initialize eeprom
	   Receivedpackage.bytes[0]='$';
	   Receivedpackage.bytes[1]='V';
	   Receivedpackage.bytes[2]='x';
	   Receivedpackage.bytes[3]='x';
   	}

	   	   /*Initialize Sensors*/

   init_acceler();			//initialize accelerometer

 	  	  /* Initialize interrupts sources*/
EnRtcInter();								//Initialize RTC Interrupt Source
EnUsartInter();								//Enable the USART Interrupts
//EnPVDInter();      						//Enable the power PVD
//EnExtInter();								//Initialize External Interrupt Source
//EnTimInterr();								//Initialize Timer Interrupt Source

}
Exemplo n.º 20
0
void setup_avr(void) {
	// Run at 8Mhz
	CLKPR = (1 << CLKPCE); // Enable changing clock prescaler
	CLKPR = 0;             // Set to 8Mhz (no divider)

	// Set port directions to output
	DDRB |= (1 << LED);

#if DEBUG
	initUSART();
	printString("Therm running\r\n");
#endif
}
Exemplo n.º 21
0
void InitializeUSART(void)
{
	uchar i;
//	Initialize	the	arrays
	for	(i=0; i<sizeof(USB_Out_Buffer);	i++){
		USB_Out_Buffer[i] =	0;
	}

	NextUSBOut = 0;
	LastRS232Out = 0;
	lastTransmission = 0;

	initUSART();
}
Exemplo n.º 22
0
int main()
{
  uint8_t target_speed; // From user input

  // Configure timer 0 (8 bits) for PWM to control motor speed
  TCCR0A |= ((1 << WGM00) | (1 << WGM01)); // Fast PWM. Table 15-8 mode 3
  TCCR0A |= (1 << COM0B1);                 // Output to OC0B/PD5. Table 15-6
  TCCR0B |= (1 << CS02);                   // Clock to CPU/256. Table 15-9
  // TCCR0B |= ((1 << CS02) | (1 << CS00));   // CPU/1024. Makes motor pulse

  // Controls PWM duty cycle. Continuously compared with TCNT0
  OCR0B = 0;

  // Enable output on the PWM line and on rampup/rampdown LED indicator pins
  DDRD |= (1 << PD5);
  DDRB = ((1 << PB0) | (1 << PB1));

  initUSART();

  printString("DC Motor PWM speed controller\r\n");
  printString("Enter a speed [000-255]:\r\n");
  while (1)
  {
    target_speed = getNumber(); // From USART (blocking)

    // Ramp up to target
    while (OCR0B < target_speed)
    {
      OCR0B++;
      PORTB |= (1 << PB0);
      _delay_ms(RAMP_DELAY);
    }

    // Ramp down to target
    while (OCR0B > target_speed)
    {
      OCR0B--;
      PORTB |= (1 << PB1);
      _delay_ms(RAMP_DELAY);
    }

    PORTB = 0; // Indicator LEDs off

  }

  return 0;
}
Exemplo n.º 23
0
int main(void) {
  char byte;
  uint16_t timerValue;

  // -------- Inits --------- //

  initUSART();
  initTimer1();
  LED_DDR = 0xff;                               /* all LEDs for output */
  BUTTON_PORT |= (1 << BUTTON);             /* enable internal pull-up */

  printString("\r\nReaction Timer:\r\n");
  printString("---------------\r\n");
  printString("Press any key to start.\r\n");

  // ------ Event loop ------ //
  while (1) {

    byte = receiveByte();                             /* press any key */
    printString("\r\nGet ready...");
    randomDelay();

    printString("\r\nGo!\r\n");
    LED_PORT = 0xff;                                     /* light LEDs */
    TCNT1 = 0;                                        /* reset counter */

    if (bit_is_clear(BUTTON_PIN, BUTTON)) {
            /* Button pressed _exactly_ as LEDs light up.  Suspicious. */
      printString("You're only cheating yourself.\r\n");
    }
    else {
      // Wait until button pressed, save timer value.
      loop_until_bit_is_clear(BUTTON_PIN, BUTTON);
      timerValue = TCNT1 >> 4;
      /* each tick is approx 1/16 milliseconds, so we bit-shift divide */

      printMilliseconds(timerValue);
      printComments(timerValue);
    }

    // Clear LEDs and start again.
    LED_PORT = 0x00;
    printString("Press any key to try again.\r\n");

  }                                                  /* End event loop */
  return (0);                            /* This line is never reached */
}
Exemplo n.º 24
0
int main(void)
{
	DDRA = 0xFF; PORTA = 0x00;
	DDRB = 0xFF; PORTB = 0x00;
	DDRC = 0xFF; PORTC = 0x00;
	DDRD = 0xBF; PORTD = 0x40;
	TimerSet(10);
	TimerOn();
	initUSART(0);
	state = init;
	while(1)
	{
		Tick_Fct();
		while(!TimerFlag);
		TimerFlag = 0;
	}
}
Exemplo n.º 25
0
int main() {

   DDRB = (1 << PB4);
   DDRD |= (1 << PD2)|(1 << PD3);

   sei();

   initUSART();
   initSPI();
   initADC();

   while(1){
      if(PINB & (1 << PB2)) {
         SPIReset();
      }
   }
}
Exemplo n.º 26
0
int main(void) {
    cli();
    cycleData.intFlag = 0;
    cycleData.Cnt = 0;
    initWheelData();
    initPorts();
    initTimers();
    initUSART();
    initInterrupts();
    sei();
    for(;;) {
        if(cycleData.intFlag)
            prgm800Hz();
        if(cycleData.Cnt == 8)
            prgm100Hz();
    }
}
Exemplo n.º 27
0
int main(void){
// ----- Initialize ----- //
 uint16_t xaxis; 	//PC0 ADC VALUE
 uint16_t yaxis; 	//PC1 ADC VALUE 
 DDRB |= (1 <<PB0)|(1<<PB5)|(1<<PB6)|(1<<PB7);
 PORTC |= (1<<PC2); 	//THUMBSTICK PIN PULLUP RESISTOR SET

 initUSART();
 initADC();
 initPWM();
 OCR1B = VERT_MAX_POS;

 while(1){
  xaxis = readADC(PC0);
  yaxis = readADC(PC1);

  //X-AXIS 360 DEGREE ROTATION 
  if(xaxis == 514 || xaxis == 515)
	OCR1A = 1023;
  else if(xaxis < 514)
	OCR1A = 180;
  else
	OCR1A = rotateRight(xaxis);
  
  if(yaxis < 500 && OCR1B > VERT_MIN_POS){
	if(yaxis >=300)
		OCR1B -=LOWSPEED;
	else if(yaxis >=100)
		OCR1B -=MEDIUMSPEED;
	else
		OCR1B -=HIGHSPEED;

  }else if(yaxis > 530 && OCR1B < VERT_MAX_POS){
	if(yaxis <=700)
		OCR1B +=LOWSPEED;
	else if(yaxis <=900)
		OCR1B +=MEDIUMSPEED;
	else
		OCR1B +=HIGHSPEED;
   }
 _delay_ms(20); 
checkJButtonState();
}
 return(0);
 }
Exemplo n.º 28
0
int main(void) {
	clock_prescale_set(clock_div_16);

	uint8_t dummy;

	initUSART();
	initFreerunningADC();
	
	while (1) {
		//transmitByte(ADCH);	
		dummy = ADCH;
		dummy = ADCL;
		transmitByte(dummy);	
		_delay_ms(SAMPLE_DELAY);
	}

	return (0);
}
int main(void) {
  char serialCharacter;

  // -------- Inits --------- //
  LED_DDR = 0xff;                            /* set up LEDs for output */
  initUSART();
  printString("Hello World!\r\n");                          /* to test */

  // ------ Event loop ------ //
  while (1) {

    serialCharacter = receiveByte();
    transmitByte(serialCharacter);
    LED_PORT = serialCharacter;
                           /* display ascii/numeric value of character */

  }                                                  /* End event loop */
  return 0;
}
Exemplo n.º 30
0
int main()
{
	uint8_t i;

	cli();

	wdt_enable(WDTO_60MS);

	for (i = 0; i < 8; i++) {
		PORTA = PORTA >> 1;
		PORTA |= ((readEEPROM(i) - '0') & 0x01) << 7;
	}

	for (i = 8; i < 16; i++) {
		PORTC = PORTC >> 1;
		PORTC |= ((readEEPROM(i) - '0') & 0x01) << 7;
	}

	DDRA = 0xff;
	DDRC = 0xff;

	for (stackTail = EEPROM_SIZE - 1; readEEPROM(stackTail) != 0xff; stackTail--);

	status = ((uint16_t) PORTC) << 8 | (uint16_t) PORTA;

	initUSART();

	setDuty();

	initTimer0();

	initTimer2();

	sei();

	printf("\nEntering the main loop\n");
	while (1) {
		wdt_reset();
	}

	return 0;
}