Das ist mein Programm:
Code:
#include "RP6RobotBaseLib.h"
// Achtung! Die PWM-Werte werden hier OHNE Rampe verändert!
void setMotorPWM(uint8_t power_links, uint8_t power_rechts)
{
extern uint8_t mleft_ptmp, mright_ptmp;
if(power_links > 210) power_links = 210;
if(power_rechts > 210) power_rechts = 210;
mleft_power=mleft_ptmp=power_links;
mright_power=mright_ptmp=power_rechts;
OCR1BL = power_links;
OCR1AL = power_rechts;
if(power_links || power_rechts)
TCCR1A = (1 << WGM11) | (1 << COM1A1) | (1 << COM1B1);
else
TCCR1A = 0;
}
int main(void)
{
initRobotBase();
while(1)
{
writeInteger(readADC(ADC_ADC0), 10);
writeString_P(" - ");
writeInteger(readADC(ADC_ADC1), 10);
writeString_P("\n\r");
if (readADC(ADC_ADC1)) > (readADC(ADC_ADC0))
setLEDs(4);
setMotorPWM(100,50);
}
else
{
setLEDs(32);
setMotorPWM(50,100);
}
mSleep(100);
}
return(0);
}
Dann habe ich die LDR an adc0 und adc1 angeschlossen
Lesezeichen