Anodo (+) Catodo (-) Esempi: Rosso _ Rosso – Nero- Nero + (Marrone) = 220 ohm Marrone – Nero – Nero – Marrone + (Marrone) = 1 Kohm Marrone – Nero- Nero.

Slides:



Advertisements
Similar presentations
Wireless Cue Light Project
Advertisements

Khaled A. Al-Utaibi Interfacing an LED The Light Emitting Diode (LED) Applications DC Characteristics & Operation Interfacing to.
EMS1EP Lecture 8 Pulse Width Modulation (PWM)
ARDUINO CLUB What we’re really doing. BASICS The setup() and loop() functions.
Anurag Dwivedi & Rudra Pratap Suman.  Open Source electronic prototyping platform based on flexible easy to use hardware and software.
Digital & Analog Inputs. Review Fundamental parts of an Arduino program are … Setting output types using pinMode. Declaring variables Can write a digital.
Introduction to Arduino Programming January MER-421:Mechatronic System Design.
User-defined functions in Arduino sketches living with the lab © 2012 David Hall.
ELCT 201 week 13 Analog ON/OFF control system conversion to Digital ON/OFF control system.
Living with the Lab Using servos with an Arduino EAS 199A Fall 2011.
Basic Circuits – Lab 2 Arduino and Sensors Xmedia Spring 2011.
ARDUINO PROGRAMMING Working with the Arduino microcontroller.
Basic Circuits – Lab 2 Arduino and Sensors
Manufacturing Advanced Design Applications Manufacturing © 2014 International Technology and Engineering Educators Association, STEM  Center for Teaching.
Pulse Width Modulation (PWM). 100% Pulse Width Modulation (PWM) 0% On the chipKIT there are 490 periods per second. Use analogWrite(pin, value) to control.
Good LED Circuit 5V0 GND. What Voltage Does Meter See? Answer: 5 V.
ARDUINO 1. Basics  Comments  /* * Blink * * The basic Arduino example. Turns on an LED on for one second, * then off for one second, and so on... We.
Arduino Circuits and Code. int ledPin = 9; void setup() { pinMode(ledPin, OUTPUT); } void loop() { digitalWrite(ledPin, LOW); delay(1000); digitalWrite(ledPin,
Basic Circuits – Lab 4 Serial and OSC (maybe some theory too) Xmedia Spring 2011.
Microcontroller Hands-on Workshop #2 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers October 31, 2009.
Arduino Training New Mexico Mathematics, Engineering, and Science Achievement (NM MESA) Getting Started.
Line following tips photoresistors positioned near floor photoresistor circuits © 2011 LWTL faculty team living with the lab.
Arduino libraries Datatekniker Udvidet hardware/software.
Photoresistor resistance changes dramatically with light level living with the lab Using Photoresistors with an Arduino © 2011 LWTL faculty team.
Microcontroller basics Embedded systems for mortals.
Lecture 9: Introduction to Arduino Topics: Arduino Fundamentals, Bean Date: Mar 22, 2016.
Robotics Grant Agreement No LLP UK-LEONARDO-LMP Project acronym: CLEM Project title: Cloud services for E-Learning in Mechatronics Technology.
LAB1 TYWU. Devices Dip Switch (4 Switches) Triple Output LED (RGB) –Common Cathode.
Introduction to Arduino A very basic intro to Arduino, the IDE and the Servos class.
Arduino DC Motor Motion Control Instructor: Dr Matthew Khin Yi Kyaw.
Arduino + Bluetooth TYWu. Connection Arduino + Bluetooth Module.
:Blink Blink: Er. Sahil Khanna
Istituto Tecnico Industriale A.Monaco EURLAB Control a Servo Motor If you want to swing an robot arm or … steer a robot you need a special motor (Servo).
INTERNET OF EVERYTHING SDU 2016 Week 9. Physical Output  Make things move by controlling motors with Arduino  Servo-motors  Rotary actuator that allows.
Arduino “Getting Started” Instructor : Dr Matthew Miss Khin Yi Kyaw
Pulse-Width Modulation: Simulating variable DC output
ME 120: Arduino Programming Arduino Programming Part 1 ME 120 Mechanical and Materials Engineering Portland State University
Microcontroller basics Embedded systems for mortals.
Pulse Width Modulation Instructor Dr Matthew Khi Yi Kyaw.
Hacking on Arduino George Patterson
Microcontroller basics
CU ATLAS Practical electronics Motion and Servos
Microcontroller basics
Arduino.
Wireless Cue Light Project
Get Your Project Started with Arduino
Arduino motor control using servo & ultrasonic sensor
Get Your Project Started with Arduino
Lab 1: Arduino Basics Topics: Arduino Fundamentals, First Circuit
Line Following Tips photoresistor circuits
INC 161 , CPE 100 Computer Programming
3.0 ARDUINO WORKSHOP PRESENTATION FOR STUDENTS IN 4º DEGREE OF COMPULSORY SECONDARY EDUCATION 3.0.
Arduino.
Въведение в Arduino.
Arduino - Introduction
Analog Input through POT
Introduction to Arduinos
Servos and Stepper Motors
Using Photoresistors with an Arduino
Line Following Tips photoresistor circuit
CS4101 Introduction to Embedded Systems Lab 8: Arduino DAC and PWM
Topics: Programming Constructs: loops & conditionals Digital Input
Arduino : Introduction & Programming
Programming 2: The Arduino IDE & First Sketches
Arduino Practice: Photoresistors, PWM, Potentiometers, Motors
Assist. Prof. Rassim Suliyev - SDU 2018
Sensors and actuators Sensors Resistive sensors
Setting up a basic program with Arduino
Introduction to Arduinos
Arduino程式範例.
Presentation transcript:

Anodo (+) Catodo (-)

Esempi: Rosso _ Rosso – Nero- Nero + (Marrone) = 220 ohm Marrone – Nero – Nero – Marrone + (Marrone) = 1 Kohm Marrone – Nero- Nero – Rosso + (Marropne) = 10 Kohm Marrone – Nero – Nero – Arancio + (Marrone) = 100 Kohm

const int LED = 12; // LED connected to digital pin 12 void setup() { pinMode(LED, OUTPUT); // sets the digital pin as output } void loop() { digitalWrite(LED, HIGH); // turns the LED on delay(1000); // waits for a second digitalWrite(LED, LOW); // turns the LED off delay(1000); // waits for a second }

LED: Pin OUT=P9 BUTTON: Pin IN = P7

const int LED = 9; const int BUTTON = 7; int stato; void setup() { pinMode(LED, OUTPUT); pinMode(BUTTON, INPUT); } void loop() { stato=digitalRead(BUTTON); if (stato==1) {digitalWrite(LED, HIGH);} else {digitalWrite(LED, LOW);} }

… int stato_attuale,stato_passato; int luce; void setup() { … luce=0; } void loop() { stato_attuale=digitalRead(BUTTON); if ((stato_attuale-stato_passato)==1) {luce=1-luce;} digitalWrite(LED, luce); stato_passato=stato_attuale; }

const int LED = 9; const int BUTTON = 7; int pulsante_attuale,pulsante_passato,stato,luce1,luce2; void setup() { pinMode(LED, OUTPUT); pinMode(BUTTON, INPUT); stato=0; } void loop() { pulsante_attuale=digitalRead(BUTTON); if ((pulsante_attuale-pulsante_passato)==1) stato=stato+1; if (stato==3) stato=0; if (stato==0) {luce1=0;luce2=0;} if (stato==1) {luce1=1;luce2=0;} if (stato==2) {luce1=1;luce2=1;} digitalWrite(LED, luce1); delay(10); digitalWrite(LED, luce2); delay(100); pulsante_passato=pulsante_attuale; }

Diverse ampiezze vengono codificate con un duty cycle proporzionale L’ambiente Arduino lo tutto ciò fa automaticamente con la funzione Analogwrite (solo per i pin “~”) Il valore in ingresso va da 0 (spento) a 255 (acceso) Modifichiamo il codice precedente per accendere il LED a diverse intensità sfruttando questa funzione Nota: si possono modificare le proprietà del PWM agendo sui registri interni del Controllore ES: analogWrite(LED, 128)

const int LED = 9; const int BUTTON = 7; int pulsante_attuale,pulsante_passato,stato,luce; void setup() { pinMode(LED, OUTPUT); pinMode(BUTTON, INPUT); stato=0; } void loop() { pulsante_attuale=digitalRead(BUTTON); if ((pulsante_attuale-pulsante_passato)==1) stato=stato+1; if (stato==3) stato=0; if (stato==0) {luce=0;} if (stato==1) {luce=64;} if (stato==2) {luce=255;} analogWrite(LED,luce); pulsante_passato=pulsante_attuale; }

void setup() { Serial.begin(9600); // inizializzazione } void loop() { Serial.println(val); // visualizzazione }

int analogPin = 0; int val = 0; void setup() { Serial.begin(9600); } void loop() { val = analogRead(analogPin); Serial.println(val); }

#include.... Servo myservo; void setup() { myservo.attach(PIN); } void loop() {... New = map(old, low_old, high_old, low_new, high_new); myservo.write(pos);... }

ES: dht11.h #define DHTLIB_OK 0 #define DHTLIB_ERROR_CHECKSUM -1 #define DHTLIB_ERROR_TIMEOUT -2 class dht11 { public: int read(int pin); int humidity; int temperature; };

#include int analogPin = 0; int val = 0; Servo myservo; void setup() { myservo.attach(9); } void loop() { val = analogRead(analogPin); val = map(val, 200, 800, 0, 180); myservo.write(val); delay(15); }

Pilotaggio a 1 fasePilotaggio a 2 fasi

#include const int stepsPerRevolution = 2048; Stepper myStepper1(stepsPerRevolution, 8, 10, 9, 11); Stepper myStepper2(stepsPerRevolution, 4, 6, 5, 7); void setup() { myStepper1.setSpeed(10); myStepper2.setSpeed(10); } void loop() { myStepper1.step(stepsPerRevolution); myStepper2.step(-stepsPerRevolution); delay(500); myStepper1.step(-stepsPerRevolution); myStepper2.step(+stepsPerRevolution); delay(500); }

#include #define FULLSTEP 4 #define HALFSTEP 8 AccelStepper stepper1(HALFSTEP, 8, 10, 9, 11); AccelStepper stepper2(HALFSTEP, 4, 6, 5, 7); void setup() /****** SETUP: RUNS ONCE ******/ { stepper1.setMaxSpeed(1000.0); stepper1.setAcceleration(50.0); stepper1.setSpeed(200); stepper1.moveTo(8000); stepper2.setMaxSpeed(1000.0); stepper2.setAcceleration(50.0); stepper2.setSpeed(200); stepper2.moveTo(-8000); }//--(end setup )--- void loop() /****** LOOP: RUNS CONSTANTLY ******/ { //Change direction at the limits if (stepper1.distanceToGo() == 0) stepper1.moveTo(-stepper1.currentPosition()); if (stepper2.distanceToGo() == 0) stepper2.moveTo(-stepper2.currentPosition()); stepper1.run(); stepper2.run(); }//--(end main loop )---