خرید بک لینک

Vote count: 0

I wrote a sketch on my Arduino Mega when I was prototyping. Afterwards, I flashed it as is to a atmega328 chip. I got odd results all over the sketch. To fix it, I copied module by module over to a new IDE windows and that is when I noticed something fishy with the analogWrite functions. In order to take away all other variables, I uploaded this sketch which is a slightly modified FADE example sketch

int led = 6;       
int brightness = 0;
int fadeAmount = 5;
void setup() {
  Serial.begin(9600);
  pinMode(led, OUTPUT);
}
void loop() {
  Serial.println(brightness);
  analogWrite(led, brightness);
  brightness = brightness + fadeAmount;
  if (brightness == 0 || brightness == 255) {
    fadeAmount = -fadeAmount ;
  }
  delay(1000);
}

It uploads perfectly fine with no errors and I attached an led and resistor to that pin. when the chip starts ruing the code, all I get the led flashing and the serial data like this

.5
.0
.5
.0
.5
.0
.5
.0
.5
.0
.5
.0
.5
.10

What can be wrong with it???

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 13 فروردين 1395 ساعت: 4:36

صفحه بندی