Παραδείγµατα χρήσης του µικροελεγκτή Arduino Εφαρµογές για το εργαστήριο Μέρος 1 ο

Σχετικά έγγραφα
Παραδείγµατα χρήσης του µικροελεγκτή Arduino Εφαρµογές για το εργαστήριο Μέρος 2 ο :Οδήγηση Κινητήρων DC(PM)

Παραδείγµατα χρήσης του µικροελεγκτή Arduino Εφαρµογές για το εργαστήριο Μέρος 4 ο :

Arduino Teachers Workshop

FOSSCOMM ο Συνέδριο Κοινοτήτων Ανοιχτού Λογισμικού Σάββατο 20 Απριλίου Ομάδα Σχολής Ικάρων Εργαστήριο Arduino

ΕΝΟΤΗΤΑ 10: ΟΔΗΓΗΣΗ ΚΙΝΗΤΗΡΩΝ

Πλακέτα Arduino. 1ο ΕΠΑΛ Περάματος - 7ο ΕΚ Πειραιά

Προγραμματισμο ς σε Arduino

Εφαρμογές Αναλογικών Ε/Ε PWM (pulse Width Modulation)

ΑΣΚΗΣΗ 1 (22 Νοεμβρίου 2017)

Modbus basic setup notes for IO-Link AL1xxx Master Block

Εργαστηριακές σημειώσεις για το μάθημα: «Εισαγωγή στην Μηχατρονική»

ΕΡΓΑΣΤΗΡΙΟ 4 ΕΙΣΑΓΩΓΗ ΣΤΟN ARDUINO: ΨΗΦΙΑΚΗ ΕΙΣΟΔΟΣ/ΕΞΟΔΟΣ

Ενσωματωμένα Συστήματα

ΣΤΟΙΧΕΙΑ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΥ ARDUINO

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007

ΕΙΣΑΓΩΓΗ ΣΤΟ ARDUINO. Υποψήφιος Διδάκτωρ

Δρ. Π. Ασβεστάς Τμήμα Μηχανικών Βιοϊατρικής Τεχνολογίας Τ.Ε

Σχεδίαση με μικρο-ελεγκτή 8bit

Εφαρμογές βασισμένες στο Arduino

Ψηφιακά Αντικείμενα Μάθημα 1 Δραστηριότητα 1. Προγραμματισμός Φυσικών Συστημάτων. Νέα Ψηφιακά Αντικείμενα

ΚΥΠΡΙΑΚΟΣ ΣΥΝΔΕΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY 21 ος ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ Δεύτερος Γύρος - 30 Μαρτίου 2011

NMBTC.COM /

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 24/3/2007

Capacitors - Capacitance, Charge and Potential Difference

Ενσωματωμένα Συστήματα

Section 8.3 Trigonometric Equations

Potential Dividers. 46 minutes. 46 marks. Page 1 of 11

Φύλλο εργασίας 7 - Δημιουργώ τα δικά μου χρώματα με το RGB LED

Εφαρμογές Arduino Σεμινάριο Ηλεκτρονικού Τομέα

the total number of electrons passing through the lamp.

The Simply Typed Lambda Calculus

!!! )!)(!,!! )!! )! (!!)!

1ο ΕΠΑΛ Περάματος -7ο ΕΚ Πειραιά. Εφαρμογές Arduino. Σεμινάριο Ηλεκτρονικού Τομέα. Φεβρουάριος 2014

Προγραμματισμός Ρομπότ

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

Εφαρμογές αναλογικών / Ψηφιακών

DC-DC Constant Current Step-Down LED driver LDD-300L LDD-350L LDD-500L LDD-600L LDD-700L CURRENT RANGE

ΔΡΑΣΤΗΡΙΟΤΗΤΑ ΕΙΣΑΓΩΓΗ ΣΤΟ ARDUINO- 01a

CYTA Cloud Server Set Up Instructions

Εμμανουήλ Πουλάκης. Προγραμματίζοντας με τον μικροελεγκτή Arduino

Instruction Execution Times

Έλεγχος με Μικροϋπολογιστές Εργαστήριο ενσωματωμένων συστημάτων

Κωνσταντίνος Γκαλονάκης. Arduino: Προγραμματισμός στην πράξη

Quick Installation Guide

Ενσωματωμένα Συστήματα

Overview: Relay Modules

Ο μικροελεγκτής Arduino στο εργαστήριο των Θετικών Επιστημών. Χρήσιμες διευθύνσεις στο διαδίκτυο

Πρόβλημα 1: Αναζήτηση Ελάχιστης/Μέγιστης Τιμής

Μετρήσεις και συλλογή δεδομένων (Data acquisition) με μικροελεγκτές. Εισαγωγή στο Arduino. Ηλεκτρομηχανολογικός εξοπλισμός διεργασιών

Εφαρμογές Arduino Σεμινάριο Ηλεκτρονικού Τομέα

Approximation of distance between locations on earth given by latitude and longitude

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

ΑΣΚΗΣΗ 2 (29 Νοεμβρίου 2016)

Scratch Διδακτική του Προγραμματισμού. Παλαιγεωργίου Γιώργος

Οδηγίες Αγοράς Ηλεκτρονικού Βιβλίου Instructions for Buying an ebook

2017 Κατασκευάζω και Προγραμματίζω με τον μικροελεγκτή Arduino

SPEEDO AQUABEAT. Specially Designed for Aquatic Athletes and Active People

2 Composition. Invertible Mappings

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 6/5/2006

65W PWM Output LED Driver. IDLV-65 series. File Name:IDLV-65-SPEC

[1] P Q. Fig. 3.1

555 TIMER APPLICATIONS AND VOLTAGE REGULATORS

Electrical Specifications at T AMB =25 C DC VOLTS (V) MAXIMUM POWER (dbm) DYNAMIC RANGE IP3 (dbm) (db) Output (1 db Comp.) at 2 f U. Typ.

DC-DC Constant Current Step-Down LED driver LDD-300L LDD-350L LDD-500L LDD-600L LDD-700L CURRENT RANGE

Oδηγός Μελέτης & Εκπόνησης Εργαστηρίου Ηλεκτρονικής Ι

Second Order RLC Filters

Εφαρμογές Σειριακής Επικοινωνίας

How to register an account with the Hellenic Community of Sheffield.

Partial Trace and Partial Transpose

Βηµατικός Κινητήρας (step motor) Αρχή λειτουργίας Βηµατικού κινητήρα. Βασική δοµή Βηµατικού κινητήρα και διαφορές τους από τους DC κινητήρες

9.09. # 1. Area inside the oval limaçon r = cos θ. To graph, start with θ = 0 so r = 6. Compute dr

Advanced Subsidiary Unit 1: Understanding and Written Response

Example Sheet 3 Solutions

Finite Field Problems: Solutions

Calculating the propagation delay of coaxial cable

If error is detected the display will show the message "E" followed by the relative error code.

Homework 3 Solutions

(1) Describe the process by which mercury atoms become excited in a fluorescent tube (3)

Correction Table for an Alcoholometer Calibrated at 20 o C

derivation of the Laplacian from rectangular to spherical coordinates

Οδηγός Σύνταξης Κώδικα C/C++ για μικροελεγκτές

Φύλλο εργασίας 6 - Θερμόμετρο εξωτερικού χώρου. Το κύκλωμα σε breadboard

Μηχανοτρονική. Τμήμα Μηχανικών Παραγωγής και Διοίκησης 7 ο Εξάμηνο,

VBA ΣΤΟ WORD. 1. Συχνά, όταν ήθελα να δώσω ένα φυλλάδιο εργασίας με ασκήσεις στους μαθητές έκανα το εξής: Version ΗΜΙΤΕΛΗΣ!!!!

ΕΡΓΑΣΤΗΡΙΟ 6 ΟΔΗΓΗΣΗ ΑΠΕΙΚΟΝΙΣΕΩΝ SSD ΚΑΙ LCD

ASL BS ,00 ASL BS ,00 ASL BS ,80 ASL BS ,60 ASL TP SET 1 817,20 ASL TP SET 2 997,20 ASL TP SET ,20

Έλεγχος με Μικροϋπολογιστές Εργαστήριο ενσωματωμένων συστημάτων

Strain gauge and rosettes

Overview. Transition Semantics. Configurations and the transition relation. Executions and computation

Στο εστιατόριο «ToDokimasesPrinToBgaleisStonKosmo?» έξω από τους δακτυλίους του Κρόνου, οι παραγγελίες γίνονται ηλεκτρονικά.

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required)

65W PWM Output LED Driver. IDPV-65 series. File Name:IDPV-65-SPEC

IDPV-45 series. 45W PWM Output LED Driver. File Name:IDPV-45-SPEC S&E

Σχεδίαση Συστημάτων με τον Arduino Μάθημα 3. Σύστημα Συλλογής & Επεξεργασίας Μετρήσεων. Η Έννοια του Global Positioning System

EE512: Error Control Coding

Άδεια Χρήσης Το παρόν εκπαιδευτικό υλικό υπόκειται σε άδειες χρήσης Creative Commons. Για εκπαιδευτικό υλικό, όπως εικόνες, που υπόκειται σε άδεια

Jesse Maassen and Mark Lundstrom Purdue University November 25, 2013

Εργαστήριο 9. Styling with Javascript

Φύλλο εργασίας 9 - Αυτόνομο ρομποτικό όχημα αποφυγής εμποδίων

Transcript:

Εισαγωγή στην Μηχατρονική Τμήμα Μηχανολόγων Μηχανικών Τ.Ε. Τ.Ε.Ι. Κρήτης Παραδείγµατα χρήσης του µικροελεγκτή Arduino Εφαρµογές για το εργαστήριο Μέρος 1 ο Δρ. Φασουλάς Γιάννης, Επίκ. Καθηγητής Νοέμβριος 2014 1

Παραδείγµατα µπορείτε να βρείτε στην διεύθυνση http://www.arduino.cc/en/tutorial/homepage Παράδειγμα 1: Blink http://arduino.cc/en/tutorial/blink Blink Turns on an LED on for one second, then off for one second, repeatedly. int led = 13; // Pin 13 has an LED connected on most Arduino boards, give it a name: void setup() pinmode(led, OUTPUT); void loop() digitalwrite(led, HIGH); delay(1000); digitalwrite(led, LOW); delay(1000); // the setup routine runs once when you press reset: // initialize the digital pin as an output. // the loop routine runs over and over again forever: // turn the LED on (HIGH is the voltage level) // wait for a second // turn the LED off by making the voltage LOW // wait for a second 2

Παράδειγμα 2: Button http://www.arduino.cc/en/tutorial/button Button Turns on and off a light emitting diode(led) connected to digital pin 13, when pressing a pushbutton attached to pin 2. * Note: on most Arduinos there is already an LED on the board attached to pin 13. // constants won't change. They're used here to set pin numbers: const int buttonpin = 2; // the number of the pushbutton pin const int ledpin = 13; // the number of the LED pin // variables will change: int buttonstate = 0; // variable for reading the pushbutton status void setup() pinmode(ledpin, OUTPUT); pinmode(buttonpin, INPUT); // initialize the LED pin as an output: // initialize the pushbutton pin as an input: void loop() buttonstate = digitalread(buttonpin); // read the state of the pushbutton value: if (buttonstate == HIGH) // check if the pushbutton is pressed. digitalwrite(ledpin, HIGH); // if it is, the buttonstate is HIGH, turn LED on: else digitalwrite(ledpin, LOW); // turn LED off: 3

Παράδειγμα 3: Digital Read to Serial http://arduino.cc/en/tutorial/digitalreadserial Reads a digital input on pin 2, prints the result to the serial monitor int pushbutton = 2; // digital pin 2 has a pushbutton attached to it. Give it a name: void setup() // initialize serial communication at 9600 bits per second: Serial.begin(9600); pinmode(pushbutton, INPUT); // make the pushbutton's pin an input: void loop() int buttonstate = digitalread(pushbutton); // read the input pin: Serial.println(buttonState); // print out the state of the button: delay(1); // delay in between reads for stability 4

Παράδειγμα 4: Analog Read to Serial http://arduino.cc/en/tutorial/analogreadserial Reads an analog input on pin 0, prints the result to the serial monitor. Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. void setup() Serial.begin(9600); // initialize serial communication at 9600 bits per second: void loop() int sensorvalue = analogread(a0); // read the input on analog pin 0: Serial.println(sensorValue); // print out the value you read and change line: delay(1); // delay in between reads for stability 5

Παράδειγμα 5: Fading - PWM http://arduino.cc/en/tutorial/fade This example shows how to fade an LED on pin 9 using the analogwrite() function. int led = 9; int brightness = 0; int fadeamount = 5; // the pin that the LED is attached to // how bright the LED is // how many points to fade the LED by void setup() pinmode(led, OUTPUT); // declare pin 9 to be an output: void loop() analogwrite(led, brightness); // set the brightness of pin 9: brightness = brightness + fadeamount; // change the brightness for next time through the loop if (brightness == 0 brightness == 255) // reverse the direction of the fading at the ends of //the fade fadeamount = -fadeamount ; delay(30); // wait for 30 milliseconds to see the dimming effect 6

Παράδειγμα 6: Analog Read Voltage http://arduino.cc/en/tutorial/readanalogvoltage ReadAnalogVoltage Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor. Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. void setup() Serial.begin(9600); // initialize serial communication at 9600 bits per second: void loop() int sensorvalue = analogread(a0); // read the input on analog pin A0 float voltage = sensorvalue * (5.0 / 1024.0); // compute Q (analog quantization size) Serial.println(voltage); // print out the value you read: 7

Παράδειγμα 7: RGB LED, Color Fade Cycle RGB_LED_Color_Fade_Cycle.pde // LED leads connected to PWM pins const int RED_LED_PIN = 9; const int GREEN_LED_PIN = 10; const int BLUE_LED_PIN = 11; // Used to store the current intensity level of the individual LEDs int redintensity = 0; int greenintensity = 0; int blueintensity = 0; // Length of time we spend showing each color const int DISPLAY_TIME = 100; // In milliseconds void setup() // No setup required. void loop() // Cycle color from red through to green // (In this loop we move from 100% red, 0% green to 0% red, 100% green) for (greenintensity = 0; greenintensity <= 255; greenintensity+=5) redintensity = 255-greenIntensity; analogwrite(green_led_pin, greenintensity); analogwrite(red_led_pin, redintensity); delay(display_time); // Cycle color from green through to blue // (In this loop we move from 100% green, 0% blue to 0% green, 100% blue) for (blueintensity = 0; blueintensity <= 255; blueintensity+=5) greenintensity = 255-blueIntensity; analogwrite(blue_led_pin, blueintensity); analogwrite(green_led_pin, greenintensity); delay(display_time); // Cycle cycle from blue through to red // (In this loop we move from 100% blue, 0% red to 0% blue, 100% red) for (redintensity = 0; redintensity <= 255; redintensity+=5) blueintensity = 255-redIntensity; analogwrite(red_led_pin, redintensity); analogwrite(blue_led_pin, blueintensity); delay(display_time); 8

Παράδειγμα 8: Έλεγχος κινητήρα RC SERVO http://ardx.org/src/circ/circ04-code.txt #include <Servo.h> Servo myservo; // create servo object to control a servo // a maximum of eight servo objects can be created int pos = 0; // variable to store the servo position void setup() myservo.attach(9); // attaches the servo on pin 9 to the servo object void loop() for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position 9

Παράδειγμα 9: Έλεγχος κινητήρα RC SERVO με τη χρήση ποτενσιομέτρου // Controlling a servo position using a potentiometer (variable resistor) #include <Servo.h> Servo myservo; // create servo object to control a servo int potpin = 0; int val; void setup() myservo.attach(9); // attaches the servo on pin 9 to the servo object void loop() val = analogread(potpin); val = map(val, 0, 1023, 0, 179); myservo.write(val) delay(15); 10

Παράδειγμα 10: Οδήγηση Ρελέ int ledpin = 2; void setup() pinmode(ledpin, OUTPUT); void loop() digitalwrite(ledpin, HIGH); delay(1000); digitalwrite(ledpin, LOW); delay(1000); 11

Παράδειγμα 11: Έλεγχος κινητήρα DC μόνιμου μαγνήτη, http://ardx.org/src/circ/circ03-code.txt int motorpin = 9; void setup() pinmode(motorpin, OUTPUT); void loop() motoronthenoff(); //motoronthenoffwithspeed(); //motoracceleration(); void motoronthenoff() int ontime = 2500; int offtime = 1000; digitalwrite(motorpin, HIGH); delay(ontime); digitalwrite(motorpin, LOW); delay(offtime); milliseconds void motoronthenoffwithspeed() int onspeed = 200; int ontime = 2500; int offspeed = 50; int offtime = 1000; analogwrite(motorpin, onspeed); delay(ontime); analogwrite(motorpin, offspeed); delay(offtime); void motoracceleration() int delaytime = 50; //Accelerates the motor for(int i = 0; i < 256; i++) analogwrite(motorpin, i); delay(delaytime); //Decelerates the motor for(int i = 255; i >= 0; i--) analogwrite(motorpin, i); delay(delaytime); 12

Παράδειγμα 12: Έλεγχος κινητήρα με το motor shield void setup() pinmode(12, OUTPUT); //DIRECTION Motor Channel A pinmode(9, OUTPUT); // BRAKE Motor Channel A void loop() //forward @ full speed digitalwrite(12, HIGH); //Establishes forward direction of Channel A digitalwrite(9, LOW); //Disengage the Brake for Channel A analogwrite(3, 255); //Spins the motor on Channel A at full speed delay(3000); digitalwrite(9, HIGH); //Eengage the Brake for Channel A delay(1000); //backward @ half speed digitalwrite(12, LOW); //Establishes backward direction of Channel A digitalwrite(9, LOW); //Disengage the Brake for Channel A analogwrite(3, 123); //Spins the motor on Channel A at half speed delay(3000); digitalwrite(9, HIGH); //Eengage the Brake for Channel A delay(1000); Summary Operating Voltage Motor controller Max current Current sensing Free running stop and brake function Function Direction Speed (PWM) Brake Current Sensing 5V to 12V L298P, Drives 2 DC motors or 1 stepper motor 2A per channel or 4A max (with external power supply) 1.65V/A, AD converter in 3V3 for max current 2A Channel A Digital 12 Digital 3 Digital 9 Analog 0 Vin: τάση τροφοδοσίας κινητήρα µέχρι 12 volt, Channel B Digital 13 Digital 11 Digital 8 Analog 1 Gnd: Γείωση κινητήρα 13

Παράδειγμα 13: Έλεγχος φωτεινότητας με Φωτοαντίσταση LDR * A simple programme that will change the intensity of * an LED based * on the amount of light incident on * the photo resistor. * //PhotoResistor Pin int lightpin = 0; //the analog pin the photoresistor is //connected to //the photoresistor is not calibrated to any units so //this is simply a raw sensor value (relative light) //LED Pin int ledpin = 9; //the pin the LED is connected to //we are controlling brightness so //we use one of the PWM (pulse width // modulation pins) void setup() pinmode(ledpin, OUTPUT); //sets the led pin to output void loop() int lightlevel = analogread(lightpin); //Read the // lightlevel lightlevel = map(lightlevel, 0, 900, 0, 255); //adjust the value 0 to 900 to //span 0 to 255 lightlevel = constrain(lightlevel, 0, 255);//make sure the //value is betwween //0 and 255 analogwrite(ledpin, lightlevel); //write the value Pin 9 14

Παράδειγμα 14: Έλεγχος θερμοκρασίας με αναλογικό αισθητήρα Σε αυτή την εργαστηριακή άσκηση χρησιμοποιούμε το αισθητήριο θερμοκρασίας TMP36 (Precision Temperature Sensor) το οποίο διαθέτει μία αναλογική έξοδο και ευαισθησία 10 m volt/c o δ καθώς επίσης λειτουργεί με μία αρχική αντιστάθμιση (offset) των 500m volt προκειμένου να παρέχεται η δυνατότητα μέτρησης και αρνητικών θερμοκρασιών. int temperaturepin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to //the resolution is 10 mv / degree centigrade //(500 mv offset) to make negative temperatures an option void setup() Serial.begin(9600); //Start the serial connection with the copmuter //to view the result open the serial monitor //last button beneath the file bar (looks like a box with an antenae) void loop() // run over and over again float temperature = getvoltage(temperaturepin); //getting the voltage reading from the //temperature sensor temperature = (temperature 0.5) * 100; //converting from 10 mv per degree with 500 mv offset //to degrees ((volatge - 500mV) times 100) Serial.println(temperature); //printing the result delay(1000); //waiting a second * getvoltage() - returns the voltage on the analog input defined by * pin float getvoltage(int pin) return (analogread(pin) *.004882814); //converting from a 0 to 1023 digital range // to 0 to 5 volts (each 1 reading equals ~ 5 millivolts Ευαισθησία οργάνου: 10 mvolt/c o Υπάρχει ένα αρχικό offset: 500mvolt Μέγεθος αναλογικής βαθµιδοποίησης: Q=(5-0)/1024=0.004882814 15