taweili / ardublock

ArduBlock is a Block Programming Language for Arduino.
GNU General Public License v3.0
413 stars 292 forks source link

AnalogOutputBlock error #152

Closed TonyCallear closed 7 years ago

TonyCallear commented 8 years ago

analogout-error

sets pin 0 as output. It generates ...


int _ABVAR_1_whatPin = 0 ;

void setup()
{
  pinMode( _ABVAR_1_whatPin , OUTPUT); // Pin 0 as output !
}

void loop()
{
  _ABVAR_1_whatPin = 5 ;
  analogWrite(_ABVAR_1_whatPin , 60);  
  delay( 1000 );
  analogWrite(_ABVAR_1_whatPin , 120);  
  delay( 1000 );
  analogWrite(_ABVAR_1_whatPin , 240);  
  delay( 1000 );
}

Worth noting that Arduino ref says that ..."You do not need to call pinMode() to set the pin as an output before calling analogWrite()"