Für ein Schulprojekt hatte ich einige Ardunio kompatible Boards in China gekauft. Liefen bis immer problemlos.
Blos bei diesem hier habe ich erstmal ein blödes Gesicht gemacht. Ein Blick mit der Lupe auf den Chip sagte mir alles.
Hier wurde kein Atmega 328p verbaut sonder ein AVAG328P aus China.
Einmal kurz Google zur Hilfe genommen. und Problem gelöst.
Der CH340 ist in Windows 10 enthalten und wird automatisch installiert. Falls nicht Frau Google fragen.

Bitte neueste Arduino IDE verwenden. z. Z. 1.8.8

Die Software für die CPU bitte hier downloaden und entpacken.

Dann das verzeichnis Libraries und Hardware nach

c:\user\deinname\documents\Arduino kopieren.

Arduino IDE neu starten. WAVGAT im Boardmanager zuweisen. Auch an den richtigen Port denken.
Sollten beim Compilieren noch Warnings auftreten, dann die entspechende Platform.txt patchen. (....... /dokuments/arduino/hardware/avr
Anstatt:
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/{archive_file}" "{object_file}"
kommt jetzt:
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"

awavgat

 Dann habe ich festgestellt das der Chip einen 12bit AD-Wandler hat.

Bei 5V ist der AD dann 2540
Sketches die dort eine Division durch 1024 machen müssen dann auf 2540 geändert werden.

 

Arduino

Einstellungen

Nichts schlimmes das meiste ist richtig vorgegeben. Unter Tools lediglich angeben welchen Arduino, hier wär es der Uno und welche Com Windows benutzt. Nicht verwirren lassen. Der Com-Port wird von Windows auf USB umgeleitet.

Eventuell sind noch Speicherort für das Sketchbook sowie die Sprache festzulegen.

Ausgaben mit seriel.Print erfolgen auf den seriellen Monitor unter Tools.
Sie können auch das Windows-Hyperterminal  (Win-XP) benutzen Sie finden es  Zubehör Kommunikation.(Win XP) . Bei Windows 7 gibt es das nicht mehr. Verwenden Sie dann den Seriellen Monitor unter Tools in der Arduino Software. Man kann das Hyperterminal auch von Windows XP verwenden oder versuchen Sie es mit Putty.
Die Com Schnittstelle wird mit 9600Baud, 8Bit, Parity none, Stoppbit kein, Flusssteuerung keine eingestellt. Das geht nur wenn der kleine Hörer aufgelegt ist. In der Programmierung des Arduino wird 9600Baud eingestellt, das andere passt.

Das erste Programm

Arduino Anschliesen LED mit Vorwiderstand an Pin6 Arduinoprogrammierung starten.
Datei neu
den Text unten per drag and drop einfügen
Upload   und sollte funzen.

void setup()
{
  pinMode(6, OUTPUT);      // kofiguriert den Pin 6 als Output
}

void loop()
{
digitalWrite(6,HIGH);          //Pin 6 auf High
delay(1000);                        //1 sek. Pause
digitalWrite(6,LOW);
delay(1000);
}

 

 

Ich habe ein RGB LED mit Common Anode benutzt.

Das heist der Common, das ist der längste Anschluss kommt an Plus. Die 3 Farben kommen an die Ausgänge des Arduinos.
Das Programm stammt aus dem Netz. Esist sehr aufwendig aber funktioniert gut, das gesammte Farbsprktrum wird durchlaufen. Vieleicht mach ich mir mal die Mühe und schreibe selbst eins.

 

// Output
int redPin = 9;   // Rotes LED,   an  digital pin 9
int grnPin = 10;  // Günes LED, an digital pin 10
int bluPin = 11;  // Blaues LED,  an  digital pin 11
// Color arrays
int black[3]  = { 0, 0, 0 };
int white[3]  = { 100, 100, 100 };
int red[3]    = { 100, 0, 0 };
int green[3]  = { 0, 100, 0 };
int blue[3]   = { 0, 0, 100 };
int yellow[3] = { 40, 95, 0 };
int dimWhite[3] = { 30, 30, 30 };
// etc.
// Set initial color
int redVal = black[0];
int grnVal = black[1]; 
int bluVal = black[2];
int wait = 10;      // 10ms internal crossFade delay; increase for slower fades
int hold = 0;       // Optional hold when a color is complete, before the next crossFade
int DEBUG = 1;      // DEBUG counter; if set to 1, will write values back via serial
int loopCount = 60; // How often should DEBUG report?
int repeat = 3;     // How many times should we loop before stopping? (0 for no stop)
int j = 0;          // Loop counter for repeat
// Initialize color variables
int prevR = redVal;
int prevG = grnVal;
int prevB = bluVal;
// Set up the LED outputs
void setup()
{
  pinMode(redPin, OUTPUT);   // sets the pins as output
  pinMode(grnPin, OUTPUT);   
  pinMode(bluPin, OUTPUT); 
  if (DEBUG) {           // If we want to see values for debugging...
    Serial.begin(9600);  // ...set up the serial ouput 
  }
}
// Main program: list the order of crossfades
void loop()
{
  crossFade(red);
  crossFade(green);
  crossFade(blue);
  crossFade(yellow);
  if (repeat) { // Do we loop a finite number of times?
    j += 1;
    if (j >= repeat) { // Are we there yet?
      exit(j);         // If so, stop.
    }
  }
}
/* BELOW THIS LINE IS THE MATH -- YOU SHOULDN'T NEED TO CHANGE THIS FOR THE BASICS
* 
* The program works like this:
* Imagine a crossfade that moves the red LED from 0-10, 
*   the green from 0-5, and the blue from 10 to 7, in
*   ten steps.
*   We'd want to count the 10 steps and increase or 
*   decrease color values in evenly stepped increments.
*   Imagine a + indicates raising a value by 1, and a -
*   equals lowering it. Our 10 step fade would look like:
* 
*   1 2 3 4 5 6 7 8 9 10
* R + + + + + + + + + +
* G   +   +   +   +   +
* B     -     -     -
* 
* The red rises from 0 to 10 in ten steps, the green from 
* 0-5 in 5 steps, and the blue falls from 10 to 7 in three steps.
* 
* In the real program, the color percentages are converted to 
* 0-255 values, and there are 1020 steps (255*4).
* 
* To figure out how big a step there should be between one up- or
* down-tick of one of the LED values, we call calculateStep(), 
* which calculates the absolute gap between the start and end values, 
* and then divides that gap by 1020 to determine the size of the step  
* between adjustments in the value.
*/
int calculateStep(int prevValue, int endValue) {
  int step = endValue - prevValue; // What's the overall gap?
  if (step) {                      // If its non-zero, 
    step = 1020/step;              //   divide by 1020
  } 
  return step;
}
/* The next function is calculateVal. When the loop value, i,
*  reaches the step size appropriate for one of the
*  colors, it increases or decreases the value of that color by 1. 
*  (R, G, and B are each calculated separately.)
*/
int calculateVal(int step, int val, int i) {
  if ((step) && i % step == 0) { // If step is non-zero and its time to change a value,
    if (step > 0) {              //   increment the value if step is positive...
      val += 1;           
    } 
    else if (step < 0) {         //   ...or decrement it if step is negative
      val -= 1;
    } 
  }
  // Defensive driving: make sure val stays in the range 0-255
  if (val > 255) {
    val = 255;
  } 
  else if (val < 0) {
    val = 0;
  }
  return val;
}
/* crossFade() converts the percentage colors to a 
*  0-255 range, then loops 1020 times, checking to see if  
*  the value needs to be updated each time, then writing
*  the color values to the correct pins.
*/
void crossFade(int color[3]) {
  // Convert to 0-255
  int R = (color[0] * 255) / 100;
  int G = (color[1] * 255) / 100;
  int B = (color[2] * 255) / 100;
  int stepR = calculateStep(prevR, R);
  int stepG = calculateStep(prevG, G); 
  int stepB = calculateStep(prevB, B);
  for (int i = 0; i <= 1020; i++) {
    redVal = calculateVal(stepR, redVal, i);
    grnVal = calculateVal(stepG, grnVal, i);
    bluVal = calculateVal(stepB, bluVal, i);
    analogWrite(redPin, redVal);   // Write current values to LED pins
    analogWrite(grnPin, grnVal);      
    analogWrite(bluPin, bluVal); 
    delay(wait); // Pause for 'wait' milliseconds before resuming the loop
    if (DEBUG) { // If we want serial output, print it at the 
      if (i == 0 or i % loopCount == 0) { // beginning, and every loopCount times
        Serial.print("Loop/RGB: #");
        Serial.print(i);
        Serial.print(" | ");
        Serial.print(redVal);
        Serial.print(" / ");
        Serial.print(grnVal);
        Serial.print(" / ");  
        Serial.println(bluVal); 
      } 
      DEBUG += 1;
    }
  }
  // Update current values for next loop
  prevR = redVal; 
  prevG = grnVal; 
  prevB = bluVal;
  delay(hold); // Pause for optional 'wait' milliseconds before resuming the loop
}

 

Login Form