Kurs Arduino 1801

(Letzte Änderung am 3.2.2018)

Unterlagen

NodeMCU 1.0 Platine mit dem
Ultra-low-Power-32-Bit-Mikrocontroller
ESP8266



ESP8266 Arduino Dokumentation (Englisch)

Installationsanleitung

Allgemeiner Überblick über das Programmieren in Arduino


Software

Arduino für Linux 64bit aus dem Kurs (vollständig konfiguriert mit meinem »blink« Projekt:

arduino1801.zip [300MB]

»Hallo Leuchtdiode!« Minimalbeispiel

int ledBlau = D4;


void setup()
{
	// Notiz: ledBlau Ausgang !!!!
	pinMode(ledBlau, OUTPUT);
}

void loop()
{
	// LED an
	digitalWrite(ledBlau, LOW);
	delay(500);

	// LED aus
	digitalWrite(ledBlau, HIGH);
	delay(100);
}

Programm für den Fototransistor-gesteuerte Zufallszahlengenerator

blink_kim.ino (von Kim):
int led_blau = D4;

int leds[] = {
	D0,
	D1,
	D2,
	D3,

	D5,
	D6,
	D7,
	D8,
};

int led_count = 8;

void zahl(int z)
{
     	if(z == 1) {
		digitalWrite(D1, HIGH);
		digitalWrite(D2, HIGH);
		digitalWrite(D3, HIGH);
	}

	if( z == 2) {
		digitalWrite(D1, HIGH);
		digitalWrite(D7, HIGH);
		digitalWrite(D0, HIGH);
		digitalWrite(D3, HIGH);
		digitalWrite(D5, HIGH);
		digitalWrite(D6, HIGH);
	}

	if( z == 3) {
		digitalWrite(D1, HIGH);
		digitalWrite(D7, HIGH);
		digitalWrite(D0, HIGH);
		digitalWrite(D3, HIGH);
		digitalWrite(D2, HIGH);
		digitalWrite(D6, HIGH);
	}

	if( z == 4) {
		digitalWrite(D1, HIGH);
		digitalWrite(D7, HIGH);
		digitalWrite(D8, HIGH);
		digitalWrite(D3, HIGH);
		digitalWrite(D2, HIGH);
	}

	if( z == 5) {
		digitalWrite(D8, HIGH);
		digitalWrite(D7, HIGH);
		digitalWrite(D0, HIGH);
		digitalWrite(D2, HIGH);
		digitalWrite(D3, HIGH);
		digitalWrite(D6, HIGH);
	}

	if( z == 6) {
		digitalWrite(D0, HIGH);
		digitalWrite(D8, HIGH);
		digitalWrite(D5, HIGH);
		digitalWrite(D7, HIGH);
		digitalWrite(D2, HIGH);
		digitalWrite(D6, HIGH);
		digitalWrite(D3, HIGH);
	}

	if( z == 8) {
		digitalWrite(D0, HIGH);
		digitalWrite(D1, HIGH);
		digitalWrite(D5, HIGH);
		digitalWrite(D7, HIGH);
		digitalWrite(D2, HIGH);
		digitalWrite(D6, HIGH);
		digitalWrite(D3, HIGH);
		digitalWrite(D8, HIGH);
	}

      	if( z == 7) {
		digitalWrite(D1, HIGH);
		digitalWrite(D2, HIGH);
		digitalWrite(D0, HIGH);
		digitalWrite(D3, HIGH);
	}

	if( z == 9) {
		digitalWrite(D0, HIGH);
		digitalWrite(D8, HIGH);
		digitalWrite(D7, HIGH);
		digitalWrite(D1, HIGH);
		digitalWrite(D2, HIGH);
		digitalWrite(D6, HIGH);
		digitalWrite(D3, HIGH);
	}

}


void setup()
{
	// Notiz: LED Anschlüsse als Ausgang schallten!
	pinMode(led_blau, OUTPUT);

	for (int p = 0; p < led_count; p++) {
		pinMode(leds[p], OUTPUT);
	}

}

// 7 Seg. LED gemeinsame Kathode (-), an = HIGH
void leds_on()
{
	for (int p = 0; p < led_count; p++) {
		digitalWrite(leds[p], HIGH);
	}
}

void leds_off()
{
	for (int p = 0; p < led_count; p++) {
		digitalWrite(leds[p], LOW);
	}
}

int n = 1;

void loop()
{
	// LED an
	digitalWrite(led_blau, LOW);

	//leds_on();
	if ( analogRead(A0) > 400 ) {
		n = random(1,9);
		zahl(n);
		delay(10);
	} else {
		zahl(n);
		delay(1000);
	}


	// LEDs aus
	digitalWrite(led_blau, HIGH);
	leds_off();
	delay(100);
}



Bei Fragen schickt mir eine Email an capnm@capitanio.org.

Sei kreativ! Viel Spaß,
Martin Capitanio