/* ___ ___ ___ _ _ ___ ___ ____ ___ ____
* / _ \ /___)/ _ \| | | |/ _ \ / _ \ / ___) _ \| \
*| |_| |___ | |_| | |_| | |_| | |_| ( (__| |_| | | | |
* \___/(___/ \___/ \__ |\___/ \___(_)____)___/|_|_|_|
* (____/
* Infrared Remote Controller & IR Receiver demo program
* Tutorial URL https://osoyoo.com/2014/12/08/decode-infrared-remote-controller-with-ir-receiver-vs1838b/
* CopyRight www.osoyoo.com
* IRremote library must be installed before running the code
* After running the code, open your Arduino Serial monitor, then push any key in your IR remote controller,
* you will see the IR code of each key, please write down these code of each key
* in future, whey you programming IR remote control code, you can use these code to determine which key is pressed,
* and let arduino make corresponding reactions
*/
#include
int input_pin = 10; //connect D10 to IR receiver S pin
IRrecv irrecv(input_pin);
decode_results signals;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // enable input from IR receiver
}
void loop() {
if (irrecv.decode(&signals)) {
Serial.println(signals.value, HEX);
irrecv.resume(); // get the next signal
}
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//Looplicht eenvoudig
int ledler[10]={2, 3, 4, 5, 6,};

void setup(){
for(int i=2; i<7; i++){
pinMode(i, OUTPUT);
}
}

void loop(){
for(int i=2; i<7; i++){
digitalWrite(i, HIGH);
delay(1000);
digitalWrite(i, LOW);
delay(500);
}
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*
* Bas on Tech – I2C LCD
* Deze les is onderdeel van de lessen op https://arduino-lessen.nl
*
* (c) Copyright 2018 – Bas van Dijk / Bas on Tech
* Deze code en inhoud van de lessen mag zonder schriftelijke toestemming
* niet voor commerciele doeleinden worden gebruikt
*
* YouTube: https://www.youtube.com/c/BasOnTechNL
* Facebook: https://www.facebook.com/BasOnTechChannel
* Instagram: https://www.instagram.com/BasOnTech
* Twitter: https://twitter.com/BasOnTech
*
* —————————————————————————
*
* Meer informatie over I2C: https://nl.wikipedia.org/wiki/I%C2%B2C-bus
*
*
* PIN AANSLUITINGEN
*
* SDA is serial data
* SCL is serial clock
*
* GND –> GND wit
* VCC –> 5V grijs
* SDA –> A4 rood
* SCL –> A5 blauw
*
*
* I2C aansluitingen per Arduino:
* Uno, Ethernet A4 (SDA), A5 (SCL)
* Mega2560 20 (SDA), 21 (SCL)
* Leonardo 2 (SDA), 3 (SCL)
* Due 20 (SDA), 21 (SCL) of SDA1, SCL1
*
*/

// Bibliotheek voor communicatie met I2C / TWI apparaten
#include

// Bibliotheek voor het LCD scherm
#include

/*
* Stel hier in welke chip en foromaat LCD je hebt
* Gebruik 0x27 als je chip PCF8574 hebt van NXP
* Gebruik 0x3F als je chip PCF8574A hebt van Ti (Texas Instruments)
* De laatste twee getallen geven het formaat van je LCD aan
* bijvoorbeeld 20×4 of 16×2
*
*/
LiquidCrystal_I2C lcd(0x27, 20, 4);
//LiquidCrystal_I2C lcd(0x3F, 16, 2);

/*
* Dit hart-symbool is online gemaakt met de LCD symbool generator op:
* https://maxpromer.github.io/LCD-Character-Creator/
*/
byte heart[] = {
0x00,
0x0A,
0x1F,
0x1F,
0x0E,
0x04,
0x00,
0x00
};

void setup() {
lcd.init(); // initialiseer het LCD scherm
lcd.backlight(); // zet de backlight aan
lcd.createChar(1, heart); // definieer een symbool in geheugen positie 1
}

void loop() {
lcd.clear(); // wis het scherm

screen1(); // voer functie screen1 uit
delay(2000); // pauzeer 1 seconde

screen2(); // voer functie screen2 uit
delay(2000); // pauzeer 1 seconde
}

void screen1() {

lcd.setCursor(0, 0); // zet de cursor op positie 1, regel 2
lcd.print(” Oh “); // schrijf op scherm
lcd.write(1); // teken symbool uit geheugen positie 1
lcd.print(” BasOnTech.nl”); // schrijf op scherm
delay(2000);
lcd.clear();

}

void screen2() {
lcd.setCursor(1, 1); // zet de cursor op positie 5, regel 2
lcd.print(“I “); // schrijf op scherm
lcd.write(1); // teken symbool uit geheugen positie 1
lcd.print(” Arduino”); // schrijf op scherm
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*
* Bas on Tech – IR ontvanger
* Deze les is onderdeel van de lessen op https://arduino-lessen.nl
*
* (c) Copyright 2018 – Bas van Dijk / Bas on Tech
* Deze code en inhoud van de lessen mag zonder schriftelijke toestemming
* niet voor commerciele doeleinden worden gebruikt
*
* YouTube: https://www.youtube.com/c/BasOnTechNL
* Facebook: https://www.facebook.com/BasOnTechChannel
* Instagram: https://www.instagram.com/BasOnTech
* Twitter: https://twitter.com/BasOnTech
*
* —————————————————————————
*
* Originele code van:
* http://arcfn.com door Ken Shirriff
*
*/

// Importeer de IR-remote bibliotheek
#include

int IrReceiverPin = 12; // stel de variable “IrReceiverPin” in op pin 12
IRrecv irrecv(IrReceiverPin); // maak een nieuwe instantie van “irrecv” en sla deze op in de variabele “IRrecv”
decode_results results; // definieer de variable “results” om de ontvangen knop-code in op te slaan

int speed = 100;

void setup()
{
Serial.begin(9600); // Stel de seriële monitor in

pinMode(LED_BUILTIN, OUTPUT); // Initialiseer digitale pin LED_BUILTIN als een uitvoer

// In case the interrupt driver crashes on setup, give a clue
// to the user what’s going on.

// Mocht de IR-remote bibliotheek vastlopen dan kunnen we dit aan de getoonde tekst zien
Serial.println(“IR-ontvanger wordt gestart…”);
irrecv.enableIRIn(); // start de IR-ontvanger
Serial.println(“IR-ontvanger actief”);

digitalWrite(LED_BUILTIN, LOW); // Zet de ingebouwde LED uit
}

void loop() {

// Als de IR-ontvanger een signaal heeft ontvangen
if (irrecv.decode(&results)) {

// Print de ontvangen waarde als hexadecimaal
Serial.println(results.value, HEX);

// Laat de IR-ontvanger luisteren naar nieuwe signalen
irrecv.resume();

// Bepaal welke knop is ingedrukt
switch (results.value) {
case 0xFF30CF: // knop 1
speed = 100; // stel de snelheid in op 100ms
break;

case 0xFF18E7: // knop 2
speed = 500; // stel de snelheid in op 500ms
break;

case 0xFF7A85: // knop 3
speed = 1000; // stel de snelheid in op 1000ms
break;
}

}

// Knipper de ingebouwde LED met de ingestelde snelheid
digitalWrite(LED_BUILTIN, HIGH);
delay(speed);

digitalWrite(LED_BUILTIN, LOW);
delay(speed);

}
+++++++++++++++++++++++++++++++++++++++++++++

//ultrasoon sensor
/*
* Bas on Tech – Ultrasoon sensor
* Deze les is onderdeel van de lessen op https://arduino-lessen.nl
*
* (c) Copyright 2018 – Bas van Dijk / Bas on Tech
* Deze code en inhoud van de lessen mag zonder schriftelijke toestemming
* niet voor commerciele doeleinden worden gebruikt
*
* YouTube: https://www.youtube.com/c/BasOnTechNL
* Facebook: https://www.facebook.com/BasOnTechChannel
* Instagram: https://www.instagram.com/BasOnTech
* Twitter: https://twitter.com/BasOnTech
*
* —————————————————————————
*
*
* Originele code van:
* https://create.arduino.cc/projecthub/Isaac100/getting-started-with-the-hc-sr04-ultrasonic-sensor-036380
*
*
* PIN AANSLUITINGEN
*
* Vcc –> 5V
* Trig –> 12
* Echo –> 8
* GND –> GND
*
*/

const int trigPin = 12; // trigger pin
const int echoPin = 8; // echo in

float duration; // variabele voor tijdsduur als kommagetal (float)
float distance; // variabele voor afstand als kommagetal (float)

void setup() {
Serial.begin(9600); // stel de seriële monitor in
pinMode(trigPin, OUTPUT); // stel de trigger pin in als uitvoer
pinMode(echoPin, INPUT); // stel de echo pin in als invoer
}

void loop() {
digitalWrite(trigPin, LOW); // zet de trigPin op LOW
delayMicroseconds(2); // wacht 2 microseconden zodat de trigPin ook daadwerkelijk LOW is

digitalWrite(trigPin, HIGH); // zet de trigPin op HIGH om ultrasoon geluid te zenden
delayMicroseconds(10); // wacht 10 microseconden
digitalWrite(trigPin, LOW); // set de trigPin op LOW om het zenden te stoppen

duration = pulseIn(echoPin, HIGH); // vraag de tijdsduur op van hoe lang de echoPin HIGH was.
// Let op dat pulseIn het programma voor pauseert totdat er een signaal terug is ontvangen
// standaard is de timeout 1 seconden. Dus het programma staat maximaal 1 seconde stil.
distance = (duration * 0.0343) / 2; // bereken de afstand aan de hand van de snelheid van het geluid
// dit getal moet door 2 worden gedeeld omdat het geluid heen en terug is gegaan.
Serial.print(“Afstand: “); // Toon het resultaat op de seriële monitor
Serial.println(distance);

delay(100); // wacht 100ms tot een volgende meting
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
lcd sensor
#include

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
lcd.begin(16, 2);
lcd.print(” Mert Arduino &”);
lcd.setCursor(0, 1);
lcd.print(” How To Make”);
delay(5000);
lcd.clear();
lcd.print(“Arduino Projects”);
lcd.setCursor(0, 1);
lcd.print(“Tutorials & Make”);
delay(5000);
lcd.clear();
lcd.print(” SUBSCRIBE”);
lcd.setCursor(0, 1);
lcd.print(“FOR MORE VIDEOS”);
delay(5000);
lcd.clear();

}

void loop() {

}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

/*
Bas on Tech – Arduino tutorial
https://arduino-lessen.nl

PIN AANSLUITINGEN LCD

SDA is serial data
SCL is serial clock

GND –> GND (wit)
VCC –> 5V (grijs)
SDA –> A4 (rood)
SCL –> A5 (blauw)

I2C aansluitingen per Arduino:
Uno, Ethernet A4 (SDA), A5 (SCL)
Mega2560 20 (SDA), 21 (SCL)
Leonardo 2 (SDA), 3 (SCL)
Due 20 (SDA), 21 (SCL) of SDA1, SCL1

*/

//// ALGEMEEN ////

// Variabele voor het aantal milliseconden sinds de Arduino is gestart
unsigned long currentMillis = 0;

//// LCD SCHERM ////

// Bibliotheek voor communicatie met I2C / TWI apparaten
#include

// Bibliotheek voor het LCD scherm
#include

/*
Stel hier in welke chip en foromaat LCD je hebt
Gebruik 0x27 als je chip PCF8574 hebt van NXP
Gebruik 0x3F als je chip PCF8574A hebt van Ti (Texas Instruments)
De laatste twee getallen geven het formaat van je LCD aan
bijvoorbeeld 20×4 of 16×2
*/
LiquidCrystal_I2C lcd(0x27, 20, 4);
//LiquidCrystal_I2C lcd(0x3F, 16, 2);

const int LCDWidth = 20;
const int LCDHeight = 4;

/*
Dit druppel-icoon is online gemaakt met de LCD symbool generator op:
https://maxpromer.github.io/LCD-Character-Creator/
*/
const byte clockIcon[] = {
0x0E,
0x11,
0x15,
0x15,
0x17,
0x11,
0x11,
0x0E
};

const byte finishFlagIcon[] = {
0x1F,
0x15,
0x1B,
0x15,
0x1F,
0x11,
0x11,
0x11
};

const int intervalLCD = 250; // update het LCD scherm elke 250ms
unsigned long previousMillisLCD = 0; // tijdstip in milliseconden van vorige LCD update

//// DRUKKNOPPEN ////
const int intervalButtonRead = 100; // tijd in milliseconden tussen het uitlezen van de drukknop
unsigned long previousMillisButton = 0; // tijdstip in milliseconden van vorig uitleesmoment van drukknop

const int buttonStartPin = 12; // start/stop knop pin
int buttonStartState = LOW; // staat van de start/stop knop
int buttonStartStatePrevious = LOW; // vorige staat van start/stop knop

const int buttonResetPin = 10; // reset knop pin
int buttonResetState = LOW; // staat van de reset knop
int buttonResetStatePrevious = LOW; // vorige staat van reset knop

bool redrawLCD = true; // geeft aan of het scherm moet worden bijgewerkt

//// STOPWATCH ////
bool stopWatchActive = false; // geeft aan of de stopwacht loopt
unsigned long stopWatchMillis = 0; // tijdstip in milliseconden waarop stopwatch begon te lopen
unsigned long stopWatchTimeElapsed = 0; // verstreken tijd in milliseconden sinds stopwatch begon te lopen

// Start de stopwatch
void stopWatchStart() {
stopWatchMillis = currentMillis;
stopWatchActive = true;
redrawLCD = true;
}

// Stopt de stopwatch
void stopWatchStop() {
stopWatchTimeElapsed = currentMillis – stopWatchMillis;
stopWatchActive = false;
redrawLCD = true;
}

// Reset de stopwatch
void stopWatchReset() {
stopWatchActive = false;
stopWatchMillis = 0;
stopWatchTimeElapsed = 0;
buttonStartState = LOW;
buttonStartStatePrevious = LOW;
buttonResetState = LOW;
buttonResetStatePrevious = LOW;
redrawLCD = true;
}

// Functie voor het uitlezen van de drukknop
void readButtonState() {

// Als het tijdsverschil met de vorige uitlezing groter is dan intervalButtonRead
if (currentMillis – previousMillisButton > intervalButtonRead) {

// Lees de digitale waarden van de schakelaars (LOW/HIGH)
buttonStartState = digitalRead(buttonStartPin);
buttonResetState = digitalRead(buttonResetPin);

// Als de start knop is ingedrukt
if (buttonStartState == HIGH && buttonStartStatePrevious == LOW) {

// Als de stopwatch nog niet loopt start deze. Loopt de stopwatch, stop deze.
if (!stopWatchActive) {
stopWatchStart();
} else {
stopWatchStop();
}

buttonStartStatePrevious = HIGH;

}

// Als de start knop wordt losgelaten en de stopwatch loopt
if (buttonStartState == LOW && buttonStartStatePrevious == HIGH && stopWatchActive) {
buttonStartStatePrevious = LOW;
}

// Als de reset knop wordt ingedrukt, reset de stopwatch
if (buttonResetState == HIGH) {
stopWatchReset();
}

// sla het huidige tijdstip op in previousMillisButton
previousMillisButton = currentMillis;

}
}

// Functie om het LCD scherm bij te werken
void updateLCD() {

// Als het tijdsverschil met de vorige uitlezing groter is dan intervalLCD
if (currentMillis – previousMillisLCD > intervalLCD) {

if (redrawLCD || stopWatchActive) {

lcd.clear();

// Als de stopwacth niet loopt en de verstreken tijd is 0
if (!stopWatchActive && stopWatchTimeElapsed == 0) {
lcd.setCursor(0, 0); // zet de cursor op positie 1, regel 1
lcd.print(“DRUK OP DE STARTKNOP”);
lcd.setCursor(0, 2); // zet de cursor op positie 1, regel 3
lcd.print(” OM TIJD TE STARTEN”);
}

// Als de stopwatch loopt
if (stopWatchActive) {

unsigned long formattedTime = currentMillis – stopWatchMillis;

lcd.setCursor(0,0);

lcd.write(0); // teken het klok icoon van geheugenpositie 0
lcd.print(” “); // schrijf een spatie
lcd.print(formattedTime); // schrijf de verstreken tijd
lcd.print(“ms”); // schrijf ms
}

// Als de stopwatch is stop gezet
if (!stopWatchActive && stopWatchTimeElapsed > 0) {

lcd.setCursor(0,0);

lcd.write(1); // teken het finish icoon van geheugenpositie 0
lcd.print(” “); // schrijf een spatie
lcd.print(stopWatchTimeElapsed); // schrijf de opgemaakte verstreken tijd
lcd.setCursor(0, 3); // zet de cursor op positie 1, regel 4
lcd.print(“DRUK OP DE RESETKNOP”);
}

redrawLCD = false;

}

// sla het huidige tijdstip op in previousMillisLCD
previousMillisLCD = currentMillis;

}

}

void setup() {
Serial.begin(9600); // stel de seriële monitor in

// LCD
lcd.init(); // initialiseer het LCD scherm
lcd.backlight(); // zet de backlight aan
lcd.createChar(0, clockIcon); // definieer een symbool in geheugen positie 0
lcd.createChar(1, finishFlagIcon); // definieer een symbool in geheugen positie 0

}

void loop() {

currentMillis = millis(); // sla de huidige tijd op
readButtonState(); // lees de huidige staat van de drukknopen uit
updateLCD(); // werk het LCD scherm bij

}

 ++++++++++++++++++++++++++++++++++++++++++++++++=++++++
Tempmeter met lcd display
/*
 * Bas on Tech – DHT11 / DHT22
 * Deze les is onderdeel van de lessen op https://arduino-lessen.nl
 *  
 * (c) Copyright 2018 – Bas van Dijk / Bas on Tech
 * Deze code en inhoud van de lessen mag zonder schriftelijke toestemming
 * niet voor commerciele doeleinden worden gebruikt
 *
 * YouTube:    https://www.youtube.com/c/BasOnTechNL
 * Facebook:   https://www.facebook.com/BasOnTechChannel
 * Instagram:  https://www.instagram.com/BasOnTech
 * Twitter:    https://twitter.com/BasOnTech
 *
 * —————————————————————————
 *
 * PIN AANSLUITINGEN DHT11 & DHT22
 *
 * Vcc  –> 3.3V
 * Data –> 12
 * NC
 * GND  –> GND
 *
 * 4K7 (4700) Ohm weerstand tussen 3.3V en Data pin
 *
 */

#include “DHT.h”             // Bibliotheek voor DHT sensoren

// Bibliotheek voor communicatie met I2C / TWI apparaten
#include

// Bibliotheek voor het LCD scherm
#include

/*
 * Stel hier in welke chip en foromaat LCD je hebt
 * Gebruik 0x27 als je chip PCF8574 hebt van NXP
 * Gebruik 0x3F als je chip PCF8574A hebt van Ti (Texas Instruments)
 * De laatste twee getallen geven het formaat van je LCD aan
 * bijvoorbeeld 20×4 of 16×2
 *  
 */  
LiquidCrystal_I2C lcd(0x27, 16, 2);
//LiquidCrystal_I2C lcd(0x3F, 16, 2);

#define dhtPin 12            // data pin

/*
 * Stel hier in welke DHT chip je gebruikt
 */
#define dhtType DHT11        // DHT 11
//#define dhtType DHT22      // DHT 22  (AM2302), AM2321
//#define dhtType DHT21      // DHT 21 (AM2301)

DHT dht(dhtPin, dhtType);    // Initialiseer de DHT bibliotheek

float humidityVal;           // luchtvochtigheid
float tempValC;              // temperatuur in graden Celcius
float tempValF;              // temperatuur in graden Fahrenheit
float heatIndexC;            // gevoelstemperatuur in graden Celcius
float heatIndexF;            // gevoelstemperatuur in graden Fahrenheit

void setup() {
  Serial.begin(9600);        // stel de seriële monitor in

  dht.begin();               // start het DHT sensor uitlezen

  lcd.init();                  // initialiseer het LCD scherm
  lcd.backlight();             // zet de backlight aan
  lcd.clear();                 // wis het scherm

  lcd.setCursor(0, 0);
  lcd.print(“Temp=”);

  lcd.setCursor(0, 1);
  lcd.print(“Vocht=”);
}

void loop() {

  humidityVal = dht.readHumidity();        // vraag de luchtvochtigheid aan de DHT sensor
  tempValC = dht.readTemperature();        // vraag de temperatuur in graden Celcius aan de DHT sensor
  tempValF = dht.readTemperature(true);    // vraag de temperatuur in graden Fahrenheit aan de DHT sensor

  // Controleer of alle waarden goed zijn uitgelezen, zo niet probeer het opnieuw
  if (isnan(humidityVal) || isnan(tempValC) || isnan(tempValF)) {
    Serial.println(“Uitlezen van DHT sensor mislukt!”);

    // Beëindig de loop() functie
    return;
  }
 
  // Bereken de gevoelstemperatuur in graden Celcius
  heatIndexC = dht.computeHeatIndex(tempValC, humidityVal, false);

  // Bereken de gevoelstemperatuur in graden Fahrenheit
  heatIndexF = dht.computeHeatIndex(tempValF, humidityVal);

  lcd.setCursor(8, 0);
  lcd.print(tempValC);

  lcd.setCursor(8, 1);
  lcd.print(humidityVal);
 
  // Print alle waarden naar de seriële monitor
  // \t print een tab, \n print een nieuwe regel karakter
  Serial.print(humidityVal);
  Serial.print(“\t”);
  Serial.print(tempValC);
  Serial.print(“\n”);
 
  delay(2000);
}

++++++++++++++++++++++++++++++++++++++++++++++++++++