SlideShare ist ein Scribd-Unternehmen logo
1 von 2
Downloaden Sie, um offline zu lesen
#include <Servo.h> //Servo library
Servo servo_test; //Servo setup
int angle = 0; // Servo setup
// motors
int in1 = 4;
int in2 = 5;
int in3 = 6;
int in4 = 7;
unsigned long previousMillis = 0; // will store last time servos were spinning
unsigned long currentMillis = 0;
const long interval = 5000; // interval between each round of spin
int trigPin = 3; // Trigger for ultrasonic sensor
int echoPin = 2; // Echo for ultrasonic sensor
long duration, cm, inches; // ultrasonic sensor setup
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
servo_test.attach(9);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
}
void loop() {
// The sensor is triggered by a HIGH pulse of 10 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Read the signal from the sensor: a HIGH pulse whose duration is the time (in microseconds)
// from the sending of the ping to the reception of its echo off of an object.
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
cm = (duration/2) / 29.1; // Convert time into distance
delay(250);
currentMillis = millis();
if (cm < 15) {
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
} else {
// Turn on motors in FORWARD motions
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis; // save the last time spinning the servo
digitalWrite(in1, LOW); // stop all motors
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
for (angle = 0; angle < 360; angle += 5) { // turn servo 1000 degrees
servo_test.write(angle);
delay(5);
}
delay(400);
for (angle = 360; angle>=1; angle-=5) { // reverse servo back to 0 degrees
servo_test.write(angle);
delay(5);
}
delay(1000);
}
}
}

Weitere ähnliche Inhalte

Was ist angesagt?

Handling Interrupts in Microchip MCUs
Handling Interrupts in Microchip MCUsHandling Interrupts in Microchip MCUs
Handling Interrupts in Microchip MCUs
Corrado Santoro
 
LED Lighting Product Attachment
LED Lighting Product AttachmentLED Lighting Product Attachment
LED Lighting Product Attachment
Ultra LEDs
 
Using Timers in PIC18F Microcontrollers
Using Timers in PIC18F MicrocontrollersUsing Timers in PIC18F Microcontrollers
Using Timers in PIC18F Microcontrollers
Corrado Santoro
 
Exercises with timers and UART
Exercises with timers and UARTExercises with timers and UART
Exercises with timers and UART
Corrado Santoro
 
Introduction to Vortex86DX2 Motion-Control Evaluation Board
Introduction to Vortex86DX2 Motion-Control Evaluation BoardIntroduction to Vortex86DX2 Motion-Control Evaluation Board
Introduction to Vortex86DX2 Motion-Control Evaluation Board
roboard
 

Was ist angesagt? (20)

Handling Interrupts in Microchip MCUs
Handling Interrupts in Microchip MCUsHandling Interrupts in Microchip MCUs
Handling Interrupts in Microchip MCUs
 
Embedded system course projects - Arduino Course
Embedded system course projects - Arduino CourseEmbedded system course projects - Arduino Course
Embedded system course projects - Arduino Course
 
LED Lighting Product Attachment
LED Lighting Product AttachmentLED Lighting Product Attachment
LED Lighting Product Attachment
 
Micro Assignment 1
Micro Assignment 1Micro Assignment 1
Micro Assignment 1
 
Using Timers in PIC18F Microcontrollers
Using Timers in PIC18F MicrocontrollersUsing Timers in PIC18F Microcontrollers
Using Timers in PIC18F Microcontrollers
 
Exercises with timers and UART
Exercises with timers and UARTExercises with timers and UART
Exercises with timers and UART
 
Exception handling in Pipelining in COA
Exception handling in Pipelining in COAException handling in Pipelining in COA
Exception handling in Pipelining in COA
 
Snort Home Lab - Workshop
Snort Home Lab - Workshop Snort Home Lab - Workshop
Snort Home Lab - Workshop
 
Lampiran 1.programdocx
Lampiran 1.programdocxLampiran 1.programdocx
Lampiran 1.programdocx
 
Final pid2
Final pid2Final pid2
Final pid2
 
Hexapod ppt
Hexapod pptHexapod ppt
Hexapod ppt
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScript
 
The evolution of fieldbus topologies
The evolution of fieldbus topologiesThe evolution of fieldbus topologies
The evolution of fieldbus topologies
 
Using Timer2 in Microchip MCUs
Using Timer2 in Microchip MCUsUsing Timer2 in Microchip MCUs
Using Timer2 in Microchip MCUs
 
Interrupt
InterruptInterrupt
Interrupt
 
Introduction to Vortex86DX2 Motion-Control Evaluation Board
Introduction to Vortex86DX2 Motion-Control Evaluation BoardIntroduction to Vortex86DX2 Motion-Control Evaluation Board
Introduction to Vortex86DX2 Motion-Control Evaluation Board
 
Lathe Spindle Sensor
Lathe Spindle SensorLathe Spindle Sensor
Lathe Spindle Sensor
 
Programming avr microcontroller digital i
Programming avr microcontroller digital iProgramming avr microcontroller digital i
Programming avr microcontroller digital i
 
Ports 0f 8051
Ports 0f 8051Ports 0f 8051
Ports 0f 8051
 
Lab5
Lab5Lab5
Lab5
 

Ähnlich wie Mitsubachi Arduino code

CODING IN ARDUINO
CODING IN ARDUINOCODING IN ARDUINO
CODING IN ARDUINO
S Ayub
 
GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
 GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
alltiusind
 
The IoT Academy IoT training Arduino Part 5 Arduino peripherals
The IoT Academy IoT training Arduino Part 5 Arduino peripheralsThe IoT Academy IoT training Arduino Part 5 Arduino peripherals
The IoT Academy IoT training Arduino Part 5 Arduino peripherals
The IOT Academy
 
#include IRremote.hint RECV_PIN = 19;const int timer = 600.docx
#include IRremote.hint RECV_PIN = 19;const int timer = 600.docx#include IRremote.hint RECV_PIN = 19;const int timer = 600.docx
#include IRremote.hint RECV_PIN = 19;const int timer = 600.docx
katherncarlyle
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdf
SIGMATAX1
 

Ähnlich wie Mitsubachi Arduino code (20)

Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
 
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
 
Michael kontopoulo1s
Michael kontopoulo1sMichael kontopoulo1s
Michael kontopoulo1s
 
Presentation in Computer Assembly.pptx
Presentation  in Computer Assembly.pptxPresentation  in Computer Assembly.pptx
Presentation in Computer Assembly.pptx
 
CODING IN ARDUINO
CODING IN ARDUINOCODING IN ARDUINO
CODING IN ARDUINO
 
Arduino Programming
Arduino ProgrammingArduino Programming
Arduino Programming
 
GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
 GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
 
The IoT Academy IoT training Arduino Part 5 Arduino peripherals
The IoT Academy IoT training Arduino Part 5 Arduino peripheralsThe IoT Academy IoT training Arduino Part 5 Arduino peripherals
The IoT Academy IoT training Arduino Part 5 Arduino peripherals
 
DomCode 2015 - Abusing phones to make the internet of things
DomCode 2015 - Abusing phones to make the internet of thingsDomCode 2015 - Abusing phones to make the internet of things
DomCode 2015 - Abusing phones to make the internet of things
 
Sbaw090908
Sbaw090908Sbaw090908
Sbaw090908
 
selected input/output - sensors and actuators
selected input/output - sensors and actuatorsselected input/output - sensors and actuators
selected input/output - sensors and actuators
 
Waveform Generation Using TMS320C6745 DSP
Waveform Generation Using TMS320C6745 DSPWaveform Generation Using TMS320C6745 DSP
Waveform Generation Using TMS320C6745 DSP
 
Hello I hope you are doing well Would you be able to combi.pdf
Hello I hope you are doing well Would you be able to combi.pdfHello I hope you are doing well Would you be able to combi.pdf
Hello I hope you are doing well Would you be able to combi.pdf
 
MaxBotix Code Examples
MaxBotix Code ExamplesMaxBotix Code Examples
MaxBotix Code Examples
 
#include IRremote.hint RECV_PIN = 19;const int timer = 600.docx
#include IRremote.hint RECV_PIN = 19;const int timer = 600.docx#include IRremote.hint RECV_PIN = 19;const int timer = 600.docx
#include IRremote.hint RECV_PIN = 19;const int timer = 600.docx
 
Ultrsonic sensor_Arduino_DRKG.pptx
Ultrsonic sensor_Arduino_DRKG.pptxUltrsonic sensor_Arduino_DRKG.pptx
Ultrsonic sensor_Arduino_DRKG.pptx
 
Automatic Garage System using VHDL
Automatic Garage System using VHDLAutomatic Garage System using VHDL
Automatic Garage System using VHDL
 
Open bot
Open bot Open bot
Open bot
 
Arm code arduino
Arm code arduinoArm code arduino
Arm code arduino
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdf
 

Mehr von Yilin Zeng (10)

Competitive Analysis
Competitive AnalysisCompetitive Analysis
Competitive Analysis
 
Contextual Inquiry
Contextual InquiryContextual Inquiry
Contextual Inquiry
 
Group Deliverable: Interviews & Personas
Group Deliverable: Interviews & PersonasGroup Deliverable: Interviews & Personas
Group Deliverable: Interviews & Personas
 
My User Research Deliverable
My User Research DeliverableMy User Research Deliverable
My User Research Deliverable
 
project proposal
project proposalproject proposal
project proposal
 
Project: Mitsubachi
Project: MitsubachiProject: Mitsubachi
Project: Mitsubachi
 
Netflix Analysis
Netflix Analysis Netflix Analysis
Netflix Analysis
 
Seaborn graphing present
Seaborn graphing presentSeaborn graphing present
Seaborn graphing present
 
Ethnographic breaching experiment
Ethnographic breaching experiment Ethnographic breaching experiment
Ethnographic breaching experiment
 
Inclusive design playbook
Inclusive design playbookInclusive design playbook
Inclusive design playbook
 

Kürzlich hochgeladen

Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
dharasingh5698
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 

Kürzlich hochgeladen (20)

Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdf
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 

Mitsubachi Arduino code

  • 1. #include <Servo.h> //Servo library Servo servo_test; //Servo setup int angle = 0; // Servo setup // motors int in1 = 4; int in2 = 5; int in3 = 6; int in4 = 7; unsigned long previousMillis = 0; // will store last time servos were spinning unsigned long currentMillis = 0; const long interval = 5000; // interval between each round of spin int trigPin = 3; // Trigger for ultrasonic sensor int echoPin = 2; // Echo for ultrasonic sensor long duration, cm, inches; // ultrasonic sensor setup void setup() { Serial.begin (9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); servo_test.attach(9); pinMode(in1, OUTPUT); pinMode(in2, OUTPUT); pinMode(in3, OUTPUT); pinMode(in4, OUTPUT); } void loop() { // The sensor is triggered by a HIGH pulse of 10 or more microseconds. // Give a short LOW pulse beforehand to ensure a clean HIGH pulse: digitalWrite(trigPin, LOW); delayMicroseconds(5); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Read the signal from the sensor: a HIGH pulse whose duration is the time (in microseconds) // from the sending of the ping to the reception of its echo off of an object. pinMode(echoPin, INPUT); duration = pulseIn(echoPin, HIGH); cm = (duration/2) / 29.1; // Convert time into distance delay(250); currentMillis = millis();
  • 2. if (cm < 15) { digitalWrite(in1, LOW); digitalWrite(in2, LOW); digitalWrite(in3, LOW); digitalWrite(in4, LOW); } else { // Turn on motors in FORWARD motions digitalWrite(in1, HIGH); digitalWrite(in2, LOW); digitalWrite(in3, HIGH); digitalWrite(in4, LOW); if (currentMillis - previousMillis >= interval) { previousMillis = currentMillis; // save the last time spinning the servo digitalWrite(in1, LOW); // stop all motors digitalWrite(in2, LOW); digitalWrite(in3, LOW); digitalWrite(in4, LOW); for (angle = 0; angle < 360; angle += 5) { // turn servo 1000 degrees servo_test.write(angle); delay(5); } delay(400); for (angle = 360; angle>=1; angle-=5) { // reverse servo back to 0 degrees servo_test.write(angle); delay(5); } delay(1000); } } }