//enable de interne pull-up weerstand. //variabele sensorval. //naar de seriële monitor

Vergelijkbare documenten
th_elt Hardware & Software

Deel 8: stappenmotoren en interrupts

PIR DC-SWITCH. DC Passive infra-red Detector. Model No. PDS-10 GEBRUIKSAANWIJZING/INSTRUCTION MANUAL

RCL Arduino Workshop 1

SAMPLE 11 = + 11 = + + Exploring Combinations of Ten + + = = + + = + = = + = = 11. Step Up. Step Ahead

Jeroen uit. Extra informatie. Voor de lunch. Arduino zo aangesloten om mijn code te laten werken. (versie voor lunch) (code voor de lunch)

1. Sluit de LED aan zoals afgebeeld 2. Sluit de USB-kabel aan op de Arduino 3. Klik op de knop uploaden 4. De LED begint te knipperen

Arduino Workshop 1 Zuid-Limburg

MyDHL+ Van Non-Corporate naar Corporate

Arduino[4KIDS] Maak je eigen muziekinstrument!

L.Net s88sd16-n aansluitingen en programmering.

Firewall van de Speedtouch 789wl volledig uitschakelen?

Werkbladen voor Arduino workshop 1

L.Net s88sd16-n aansluitingen en programmering.

Workshop Arduino - deel 2

ALGORITMIEK: answers exercise class 7

DALISOFT. 33. Configuring DALI ballasts with the TDS20620V2 DALI Tool. Connect the TDS20620V2. Start DALISOFT

Na de intro zijn wij begonnen met concepten, en hebben we elk idee dat we hadden op geschreven.

Quick start guide. Powerbank MI Mah. Follow Fast All rights reserved. Page 1

Add the standing fingers to get the tens and multiply the closed fingers to get the units.

Settings for the C100BRS4 MAC Address Spoofing with cable Internet.

!!!! Wild!Peacock!Omslagdoek!! Vertaling!door!Eerlijke!Wol.!! Het!garen!voor!dit!patroon!is!te!verkrijgen!op! Benodigdheden:!!

The first line of the input contains an integer $t \in \mathbb{n}$. This is followed by $t$ lines of text. This text consists of:

Luister alsjeblieft naar een opname als je de vragen beantwoordt of speel de stukken zelf!

Tweede workshop Arduino

MAKERKLAS WORKSHOP ARDUINO. Maandag 7 december 2015

MyDHL+ ProView activeren in MyDHL+

/ /

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE. Toets Inleiding Kansrekening 1 8 februari 2010

Procedure Reset tv-toestellen:

Preschool Kindergarten

Today s class. Digital Logic. Informationsteknologi. Friday, October 19, 2007 Computer Architecture I - Class 8 1

1. Testdata TA sensor met Ohmse belasting

8+ 60 MIN Alleen te spelen in combinatie met het RIFUGIO basisspel. Only to be played in combination with the RIFUGIO basicgame.

Programmeren met Arduino-software

RECEPTEERKUNDE: PRODUCTZORG EN BEREIDING VAN GENEESMIDDELEN (DUTCH EDITION) FROM BOHN STAFLEU VAN LOGHUM

Arduino cursus. Eelco Dijkstra Steunpunt Informatica - Its Academy 24 september 2015

Handleiding Zuludesk Parent

Classification of triangles

My Inspiration I got my inspiration from a lamp that I already had made 2 years ago. The lamp is the you can see on the right.

ANGSTSTOORNISSEN EN HYPOCHONDRIE: DIAGNOSTIEK EN BEHANDELING (DUTCH EDITION) FROM BOHN STAFLEU VAN LOGHUM

Esther Lee-Varisco Matt Zhang

Arduino cursus 2018 voor beginners en gevorderden 23 september Paul van de Veen

B1 Woordkennis: Spelling

NSPYRE LEGO MINDSTORMS UITDAGING (JAVA) INLEIDING. DOEL: SIMULATOR:

De grondbeginselen der Nederlandsche spelling / Regeling der spelling voor het woordenboek der Nederlandsche taal (Dutch Edition)

Free time! Better skills. Free time with Brenda and Brian. Worksheet

OUTDOOR HD BULLET IP CAMERA PRODUCT MANUAL

Handleiding Digipass DP310

BathySurvey. A Trimble Access hydrographic survey module

Travel Survey Questionnaires

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE

Four-card problem. Input

Het beheren van mijn Tungsten Network Portal account NL 1 Manage my Tungsten Network Portal account EN 14

This appendix lists all the messages that the DRS may send to a registrant's administrative contact.

OUTDOOR HD DOME IP CAMERA PRODUCT MANUAL GB - NL

Oefening 1 - Seriële communicatie via USB

2019 SUNEXCHANGE USER GUIDE LAST UPDATED

Contents. Introduction Problem Definition The Application Co-operation operation and User friendliness Design Implementation

HANDLEIDING - ACTIEVE MOTORKRAAN

LDAP Server on Yeastar MyPBX & tiptel 31xx/32xx series

ANT S KINGDOM Here is some advice for setting up your Master Ant Farm!

WEGWIJZER VOOR METHODEN BIJ PROJECTMANAGEMENT (PROJECT MANAGEMENT) (DUTCH EDITION) BY EDWIN BAARDMAN, GERARD BAKKER, JAN VAN BEIJNHEM, FR

General info on using shopping carts with Ingenico epayments

Group work to study a new subject.

Introductie in flowcharts

Deel 1: Arduino kennismaking. Wat is een microcontroller, structuur van een programma, syntax,

Function checklist for the ML-350 or XL-350 with a print set. Missing loop.

HANDBOEK HARTFALEN (DUTCH EDITION) FROM BOHN STAFLEU VAN LOGHUM

Engels op Niveau A2 Workshops Woordkennis 1

The genesis of the game is unclear. Possibly, dominoes originates from China and the stones were brought here by Marco Polo, but this is uncertain.

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE

modellering met Arduino mini module

by Jody Culkin Bronnen die gratis gebruikt, verspreid of aangepast kunnen worden. meestal software of hardware.

modellering met Arduino project module

Duurzaam projectmanagement - De nieuwe realiteit van de projectmanager (Dutch Edition)

Arduino. C.F.J. Pols.

Hoe te verbinden met NDI Remote Office (NDIRO): Apple OS X How to connect to NDI Remote Office (NDIRO): Apple OS X

Ontpopping. ORGACOM Thuis in het Museum

DDS chips. DDS = Direct Digital (frequency) Synthesis. Output = sinusvormig signaal. Maximum frequentie = ½ klokfrequentie

z x 1 x 2 x 3 x 4 s 1 s 2 s 3 rij rij rij rij

Vertaling Engels Gedicht / songteksten

Arduino : Morse Voltmeter

The colour of a pixel in a bit map picture can be presented in different ways. For this assignment, we distinguish two categories:

i(i + 1) = xy + y = x + 1, y(1) = 2.

Calculator spelling. Assignment

Arduino Programmeer handleiding

delay(1000); // Eén seconde pauze digitalwrite(pin, LOW); // zet 'pin' uit delay(1000); // Eén seconde pauze }

by Jody Culkin Bronnen die gratis gebruikt, verspreid of aangepast kunnen worden. meesta software of hardware.

NEDERLANDS. Display Instructies. Knoppen. Geeft afwisselend Tijd, Datum en Temperatuur weer, kan ook ingesteld worden op enkel tijd

Interface tussen Stuurbediening en Sony autoaudio

FAAC DRIVER. Driver install procedure for FAAC boards. Installatieprocedure voor driver voor FAAC-kaarten.

EM7680 Firmware Update by Micro SD card

Het is geen open boek tentamen. Wel mag gebruik gemaakt worden van een A4- tje met eigen aantekeningen.

Een vrouw, een kind en azijn (Dutch Edition)

it600 Smart Home Range


Alistair LED stairwell luminaire Handleiding Alistair (Emergency UC03 sensor)

Alistair LED stairwell luminaire Handleiding Alistair (UC03 sensor)

Transcriptie:

Keuzestructuren void setup() { Serial.begin(9600); pinmode(0, INPUT_PULLUP); pinmode(2, OUTPUT); pinmode(3, OUTPUT); void loop() { int sensorval = digitalread(0); Serial.println(sensorVal); //start seriële verbinding //configureer pin0 als een input en //enable de interne pull-up weerstand //configureer pin2 als een output //configureer pin3 als een output //lees de waarde van de drukknop en zet deze in de //variabele sensorval //Stuur de waarde van de drukknop (sensorval) //naar de seriële monitor // Door de pullup-weerstand reageert de uitgang geinverteerd op de stand van de schakelaar // De uitgang is HOOG (logisch 1 ) als de schakelaar open is. // De uitgang is LAAG (logisch 0 ) als de schakelaar dicht is. // if..then..else functie if (sensorval == HIGH) { digitalwrite(2, LOW); digitalwrite(3, HIGH); else { digitalwrite(2, HIGH); digitalwrite(3, LOW); //Als de variabele sensorval hoog is dan // Zet uitgang 2 LAAG PSD if..then..else functie (Selectie) // Zet uitgang 3 HOOG //Anders // Zet uitgang 2 HOOG // Zet uitgang 3 LAAG Ja then.. Voorwaarde if Nee Else.. Pull up weerstand Vcc 0A R1 10kΩ S1 0V Vin (5V) 5V Vcc 0,5mA R1 10kΩ S1 5V Vin (0V) 0V Een ingang mag nooit zweven (los hangen). Op een loshangende ingang kan door straling een HOOG-signaal (logische 1 ) komen te staan. Een manier om dit te voorkomen is een pull-up weerstand. Als in het schema hierlangs de schakelaar open staat, dan is de spanning Vi = 5V. Vi zit vast aan een ingang die een hele hoge weerstand heeft. Hierdoor loopt er geen stroom door de weerstand. U = I * R -> U = 0A * 10.10 3 = 0V. Er is dus geen spanningsval over de weerstand. Als de schakelaar gesloten wordt hangt Vi direct aan de massa. Vi wordt dan 0V. Er gaat dan wel een stroom lopen door de weerstand: I = U/R = 5V/10.10 3 =0,5.10-3 = 0,5 ma

/* State change detection (edge detection) Often, you don't need to know the state of a digital input all the time, but you just need to know when the input changes from one state to another. For example, you want to know when a button goes from OFF to ON. This is called state change detection, or edge detection. This example shows how to detect when a button or button changes from off to on and on to off. The circuit: * pushbutton attached to pin 2 from +5V * 10K resistor attached to pin 2 from ground * LED attached from pin 13 to ground (or use the built-in LED on most Arduino boards) http://www.arduino.cc/en/tutorial/buttonstatechange */ // this constant won't change: const int buttonpin = 2; const int ledpin = 13; // Variables will change: int buttonpushcounter = 0; int buttonstate = 0; int lastbuttonstate = 0; // the pin that the pushbutton is attached to // the pin that the LED is attached to // counter for the number of button presses // current state of the button // previous state of the button void setup() { pinmode(buttonpin, INPUT); pinmode(ledpin, OUTPUT); Serial.begin(9600); // initialize the button pin as a input: // initialize the LED as an output: // initialize serial communication: void loop() { buttonstate = digitalread(buttonpin); //lees de waarde van de schakelaar op ingang //buttonpin (ingang 2) if (buttonstate!= lastbuttonstate) { //Als buttonstate ongelijk(!=) is aan lastbuttonstate if (buttonstate == HIGH) { //Als buttonstate gelijk is aan (==) HOOG dan, buttonpushcounter++; //buttonpushcounter met 1 verhogen (++ -> x = x + 1) Serial.println("on"); //schrijf on Serial.print("number of button pushes: "); Serial.println(buttonPushCounter); else { //Als buttonstate gelijk is aan (==) LAAG dan, Serial.println("off"); //schrijf off delay(50); //Vertraging van 50ms om trillingen van de //schakelaar te vermijden lastbuttonstate = buttonstate; //lastbuttonstate krijgt de waarde van buttonstate //for next time through the loop // turns on the LED every four button pushes by // checking the modulo of the button push counter. // the modulo function gives you the remainder of // the division of two numbers: if (buttonpushcounter % 4 == 0) { digitalwrite(ledpin, HIGH); else { digitalwrite(ledpin, LOW);

/* Switch statement Demonstrates the use of a switch statement. The switch statement allows you to choose from among a set of discrete values of a variable. It's like a series of if statements. To see this sketch in action, but the board and sensor in a well-lit room, open the serial monitor, and and move your hand gradually down over the sensor. The circuit: * photoresistor from analog in 0 to +5V * 10K resistor from analog in 0 to ground http://www.arduino.cc/en/tutorial/switchcase */ // these constants won't change. They are the // lowest and highest readings you get from your sensor: const int sensormin = 0; // sensor minimum, experimenteel vastgesteld const int sensormax = 600; // sensor maximum, experimenteel vastgesteld void setup() { // initialize serial communication: Serial.begin(9600); void loop() { // read the sensor: int sensorreading = analogread(a0); // map the sensor range to a range of four options: int range = map(sensorreading, sensormin, sensormax, 0, 3); // do something different depending on the // range value: switch (range) { case 0: // your hand is on the sensor Serial.println("dark"); break; case 1: // your hand is close to the sensor Serial.println("dim"); break; case 2: // your hand is a few inches from the sensor Serial.println("medium"); break; case 3: // your hand is nowhere near the sensor Serial.println("bright"); break; delay(1); // delay in between reads for stability Start seriële communicatie Lees de analoge waarde op A0 en zet deze in de variabele sensorreading Zet de sensorwaarde om in een van de 4 mogelijkheden Blok 1 Schrijf "dark" Blok 2 Schrijf "dim" Einde keuzestructuur Keuzestructuur Blok 3 Schrijf "medium" Vertraging van 1 milliseconde t.b.v. stabiliteit Blok 4 Schrijf "bright"

map commando https://www.arduino.cc/en/reference/map Beschrijving De map() functie een getal om van het ene bereik naar een ander bereik (scaleren of verschalen) map(value, fromlow, fromhigh, tolow, tohigh) Value = waarde fromlow = oude lage waarde tolow = nieuwe lage waarde fromhigh = oude hoge waarde tohigh = nieuwe hoge waarde Voorbeeld_1 - verschalen map(value, fromlow, fromhigh, tolow, tohigh) map( 300, 0, 600, 0, 3 ) Value fromlow fromhigh 0 (=sensormin) 600 (=sensormax) 000 tot 200 200 tot 400 400 tot 600 tolow tohigh 0 3 0 tot 1 1 tot 2 2 tot 3 1,5 300 (voorbeeldwaarde) Voorbeeld_2 - Inverteren Je kunt de map() functie ook gebruiken voor een serie getallen te inverteren: y = map(x, 1, 50, 50, 1); map(value, fromlow, fromhigh, tolow, tohigh) map( x, 1, 50, 50, 1 ) Value fromlow fromhigh 1 (=sensormin) 50 (=sensormax) 01 02 03 04 24 25 26 27 47 46 49 50 tolow tohigh 47 (voorbeeldwaarde) 50 1 50 49 48 47 27 26 25 24 04 03 02 01 Uitwerking 4 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01

Voorbeeld_3 - Inverteren De map() functie werkt ook met negatieve getallen: y = map(x, 1, 50, 50, -100); map(value, fromlow, fromhigh, tolow, tohigh) map( x, 1, 50, 50, -100 ) Value fromlow fromhigh 1 (=sensormin) 50 (=sensormax) 01 02 03 04 24 25 26 27 47 46 49 50 tolow tohigh 47 (voorbeeldwaarde) 50 1 50-100 Uitwerking 4 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 50 40 30 20 10 00-10 -20-30 -40-50 -60-70 -80-90 -100 In bovenstaand voorbeeld zouden er bij het omzetten geen hele getallen uitkomen. De map() functie maakt echter alleen gebruik van integers (gehele getallen). Er ontstaan dus geen komma-getallen. Mocht er bij het omzetten een komma-getal ontstaan wordt deze afgekapt bij de komma en niet afgerond of gemiddeld. Voorbeelden: een 8,4 wordt een 8, een 8,9 wordt ook een 8..

The constrain() function

State Change Detection (Edge Detection) for pushbuttons Zodra je een pushbutton werkend hebt, kun je ook een schakeling maken waarin je kunt tellen hoe vaak een button is ingedrukt. Hiervoor moet je weten wanneer de button van het 0 naar 1 niveau verandert, de zogenaamde opgaande flank. Deze kun je dan tellen. Opgaande flank Once you've got a working, you often want to do some action based on how many times the button is pushed. To do this, you need to know when the button changes state from off to on, and count how many times this change of state happens. This is called state change detection or edge detection. In this tutorial we learn how to check the state change, we send a message to the Serial Monitor with the relevant information and we count four state changes to turn on and off an LED. Hardware Required Arduino or Genuino Board momentary button or switch 10k ohm resistor hook-up wires breadboard Circuit image developed using Fritzing. For more circuit examples, see the Fritzing project page Connect three wires to the board. The first goes from one leg of the pushbutton through a pull-down resistor (here 10k ohm) to ground. The second goes from the corresponding leg of the pushbutton to the 5 volt supply. The third connects to a digital I/O pin (here pin 2) which reads the button's state.

When the pushbutton is open (unpressed) there is no connection between the two legs of the pushbutton, so the pin is connected to ground (through the pull-down resistor) and we read a LOW. When the button is closed (pressed), it makes a connection between its two legs, connecting the pin to voltage, so that we read a HIGH. (The pin is still connected to ground, but the resistor resists the flow of current, so the path of least resistance is to +5V.) If you disconnect the digital I/O pin from everything, the LED may blink erratically. This is because the input is "floating" - that is, not connected to either voltage or ground. It will more or less randomly return either HIGH or LOW. That's why you need a pull-down resistor in the circuit. Schematic click the image to enlarge Code The sketch below continually reads the button's state. It then compares the button's state to its state the last time through the main loop. If the current button state is different from the last button state and the current button state is high, then the button changed from off to on. The sketch then increments a button push counter. The sketch also checks the button push counter's value, and if it's an even multiple of four, it turns the LED on pin 13 ON. Otherwise, it turns it off. /* State change detection (edge detection) Often, you don't need to know the state of a digital input all the

time, but you just need to know when the input changes from one state to another. For example, you want to know when a button goes from OFF to ON. This is called state change detection, or edge detection. This example shows how to detect when a button or button changes from off to on and on to off. The circuit: * pushbutton attached to pin 2 from +5V * 10K resistor attached to pin 2 from ground * LED attached from pin 13 to ground (or use the built-in LED on most Arduino boards) created 27 Sep 2005 modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. http://www.arduino.cc/en/tutorial/buttonstatechange */ // this constant won't change: const int buttonpin = 2; // the pin that the pushbutton is attached to const int ledpin = 13; // the pin that the LED is attached to // Variables will change: int buttonpushcounter = 0; presses int buttonstate = 0; int lastbuttonstate = 0; // counter for the number of button // current state of the button // previous state of the button void setup() { // initialize the button pin as a input: pinmode(buttonpin, INPUT); // initialize the LED as an output: pinmode(ledpin, OUTPUT); // initialize serial communication: Serial.begin(9600); void loop() { // read the pushbutton input pin: buttonstate = digitalread(buttonpin);

// compare the buttonstate to its previous state if (buttonstate!= lastbuttonstate) { // if the state has changed, increment the counter if (buttonstate == HIGH) { // if the current state is HIGH then the button // wend from off to on: buttonpushcounter++; Serial.println("on"); Serial.print("number of button pushes: "); Serial.println(buttonPushCounter); else { // if the current state is LOW then the button // wend from on to off: Serial.println("off"); // Delay a little bit to avoid bouncing delay(50); // save the current state as the last state, //for next time through the loop lastbuttonstate = buttonstate; // turns on the LED every four button pushes by // checking the modulo of the button push counter. // the modulo function gives you the remainder of // the division of two numbers: if (buttonpushcounter % 4 == 0) { digitalwrite(ledpin, HIGH); else { digitalwrite(ledpin, LOW);