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.

which core using ?

if using  smeezekitty core, , connect potmeter wiper pin pb4, using adc2.

so line

code: [select]
int potpin = 4;

should

code: [select]
int potpin = 2;


Arduino Forum > Using Arduino > Microcontrollers > analog read on attiny13


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support