analog read on attiny13
int potpin = 4;
int motorpin = 1;
int potvalue = 0;
int motorvalue = 0;
void setup()
{
pinmode(motorpin, output);
}
void loop()
{
potvalue = analogread(potpin);
motorvalue = map(potvalue, 0, 1023, 0, 255);
analogwrite(motorpin, motorvalue);
delay(20);
}
is there wrong code? trying control pwm dc motor. analogread function doesn't seem work. pwm fine cos substituted numerical value in place of motorvalue , working.
int motorpin = 1;
int potvalue = 0;
int motorvalue = 0;
void setup()
{
pinmode(motorpin, output);
}
void loop()
{
potvalue = analogread(potpin);
motorvalue = map(potvalue, 0, 1023, 0, 255);
analogwrite(motorpin, motorvalue);
delay(20);
}
is there wrong code? trying control pwm dc motor. analogread function doesn't seem work. pwm fine cos substituted numerical value in place of motorvalue , working.
Arduino Forum > Using Arduino > Microcontrollers > analog read on attiny13
arduino
Comments
Post a Comment