Components and supplies
Jumper wires (generic)
IR transmitter (generic)
IR receiver (generic)
Buzzer
Breadboard (generic)
USB-A to B Cable
SG90 Micro-servo motor
Rotary potentiometer (generic)
Arduino UNO
Alphanumeric LCD, 16 x 2
Project description
Code
IR SERVO
java
1/* 2 Controls: 3 * PAUSE to reset the number 4 * 0 to 9 keys to add a digit to the number 5 * Press or hold UP / DOWN to easly switch between different positions 6 7 Credits: 8 * Manauzzi Stefano (software) 9 * Scaldarella Francesco (hardware) 10*/ 11 12// Libraries 13#include <IRremote.h> 14#include <IRremoteInt.h> 15#include <Servo.h> 16#include <LiquidCrystal.h> 17 18// Pin you have to connect to 19int ServoPin = 8; 20int receiver = 11; 21int buzzer = 13; 22 23// Useful objects 24Servo Servo; 25IRrecv irrecv(receiver); 26decode_results results; 27 28// Initialize the display 29LiquidCrystal lcd(7, 6, 2, 3, 4, 5); 30 31// The starting position is 0 degrees. 32int ServoPosition = 0; 33int ServoPositionn = 0; 34 35// Main Function to transform the IR signal in an instruction 36int translateIR(int InitialServoPos) { 37 38 // Analise the received signal 39 switch(results.value) { 40 41 42 // Reset the number 43 case 0xFF02FD: return 0; break; 44 45 // All numbers (0-9) to set a specific degree position (0-90) 46 case 0xFF6897: return InitialServoPos * 10; break; 47 case 0xFF30CF: return InitialServoPos * 10 + 1; break; 48 case 0xFF18E7: return InitialServoPos * 10 + 2; break; 49 case 0xFF7A85: return InitialServoPos * 10 + 3; break; 50 case 0xFF10EF: return InitialServoPos * 10 + 4; break; 51 case 0xFF38C7: return InitialServoPos * 10 + 5; break; 52 case 0xFF5AA5: return InitialServoPos * 10 + 6; break; 53 case 0xFF42BD: return InitialServoPos * 10 + 7; break; 54 case 0xFF4AB5: return InitialServoPos * 10 + 8; break; 55 case 0xFF52AD: return InitialServoPos * 10 + 9; break; 56 57 // Change the position with UP / DOWN 58 case 0xFF906F: return InitialServoPos + 10; break; 59 case 0xFFE01F: return InitialServoPos - 10; break; 60 61 /* 62 // Repeat 63 case 0xFFFFFFFF: 64 // Augment the position 65 if (InitialServoPos % 10 == 1) { 66 return InitialServoPos + 10; 67 } 68 // Decrease the position 69 else if (InitialServoPos % 10 == 2) { 70 return InitialServoPos - 10; 71 } 72 break; 73 */ 74 } 75 76 77 // Don't over repeat with a secoundary background delay 78 int delayyy = 100; 79 delay(delayyy); 80} 81 82// *** Setup *** 83void setup() 84{ 85 // Start the Serial process 86 Serial.begin(9600); 87 88 // Set up the buzzer 89 pinMode(buzzer, OUTPUT); 90 91 // Set up the servo 92 Servo.attach(ServoPin); 93 94 // Set up the IR 95 irrecv.enableIRIn(); 96 97 // Initialize display LCD 98 lcd.begin(16,2); 99} 100 101// *** Main Loop *** 102void loop() { 103 104 // Receive the signal 105 if (irrecv.decode(&results)) { 106 ServoPosition = translateIR(ServoPosition); 107 irrecv.resume(); // receive the next value 108 } 109 110 // Position Adjustments 111 if (ServoPosition > 180) { 112 ServoPositionn = 180; 113 } 114 if (ServoPosition < 0) { 115 ServoPositionn = 0; 116 } else { 117 ServoPositionn = ServoPosition; 118 } 119 120 // Update the positon 121 Servo.write(ServoPositionn); 122 123 // Display 124 if (0 <= ServoPosition && ServoPosition <= 180) { 125 lcd.setCursor(0, 0); 126 lcd.print(" Degrees "); 127 lcd.setCursor(0, 1); 128 lcd.print(ServoPosition); 129 lcd.print("_______________"); 130 } 131 132 // Buzzer allarm and alert message 133 int buzzerTime = 70; 134 if (ServoPosition > 180) { 135 digitalWrite(buzzer,HIGH); 136 delay(buzzerTime); 137 digitalWrite(buzzer,LOW); 138 delay(buzzerTime); 139 lcd.setCursor(0, 0); 140 lcd.print("!!!!Error404!!!!"); 141 lcd.setCursor(0, 1); 142 lcd.print("!Invalid number!"); 143 } 144 145 // Set and apply the update delay 146 int MainDelayyyy = 1; 147 delay(MainDelayyyy); 148}
IR SERVO
java
1/* 2 Controls: 3 * PAUSE to reset the number 4 * 0 to 9 keys to 5 add a digit to the number 6 * Press or hold UP / DOWN to easly switch between 7 different positions 8 9 Credits: 10 * Manauzzi Stefano (software) 11 * 12 Scaldarella Francesco (hardware) 13*/ 14 15// Libraries 16#include <IRremote.h> 17#include 18 <IRremoteInt.h> 19#include <Servo.h> 20#include <LiquidCrystal.h> 21 22// 23 Pin you have to connect to 24int ServoPin = 8; 25int receiver = 11; 26int 27 buzzer = 13; 28 29// Useful objects 30Servo Servo; 31IRrecv irrecv(receiver); 32decode_results 33 results; 34 35// Initialize the display 36LiquidCrystal lcd(7, 6, 2, 3, 4, 5); 37 38// 39 The starting position is 0 degrees. 40int ServoPosition = 0; 41int ServoPositionn 42 = 0; 43 44// Main Function to transform the IR signal in an instruction 45int 46 translateIR(int InitialServoPos) { 47 48 // Analise the received signal 49 switch(results.value) 50 { 51 52 53 // Reset the number 54 case 0xFF02FD: return 0; break; 55 56 57 // All numbers (0-9) to set a specific degree position (0-90) 58 case 0xFF6897: 59 return InitialServoPos * 10; break; 60 case 0xFF30CF: return InitialServoPos 61 * 10 + 1; break; 62 case 0xFF18E7: return InitialServoPos * 10 + 2; break; 63 64 case 0xFF7A85: return InitialServoPos * 10 + 3; break; 65 case 0xFF10EF: 66 return InitialServoPos * 10 + 4; break; 67 case 0xFF38C7: return InitialServoPos 68 * 10 + 5; break; 69 case 0xFF5AA5: return InitialServoPos * 10 + 6; break; 70 71 case 0xFF42BD: return InitialServoPos * 10 + 7; break; 72 case 0xFF4AB5: 73 return InitialServoPos * 10 + 8; break; 74 case 0xFF52AD: return InitialServoPos 75 * 10 + 9; break; 76 77 // Change the position with UP / DOWN 78 case 0xFF906F: 79 return InitialServoPos + 10; break; 80 case 0xFFE01F: return InitialServoPos 81 - 10; break; 82 83 /* 84 // Repeat 85 case 0xFFFFFFFF: 86 // Augment 87 the position 88 if (InitialServoPos % 10 == 1) { 89 return InitialServoPos 90 + 10; 91 } 92 // Decrease the position 93 else if (InitialServoPos % 94 10 == 2) { 95 return InitialServoPos - 10; 96 } 97 break; 98 */ 99 100 } 101 102 103 // Don't over repeat with a secoundary background delay 104 int 105 delayyy = 100; 106 delay(delayyy); 107} 108 109// *** Setup *** 110void setup() 111 112{ 113 // Start the Serial process 114 Serial.begin(9600); 115 116 // 117 Set up the buzzer 118 pinMode(buzzer, OUTPUT); 119 120 // Set up the servo 121 122 Servo.attach(ServoPin); 123 124 // Set up the IR 125 irrecv.enableIRIn(); 126 127 128 // Initialize display LCD 129 lcd.begin(16,2); 130} 131 132// *** Main Loop *** 133void 134 loop() { 135 136 // Receive the signal 137 if (irrecv.decode(&results)) { 138 139 ServoPosition = translateIR(ServoPosition); 140 irrecv.resume(); // receive 141 the next value 142 } 143 144 // Position Adjustments 145 if (ServoPosition > 146 180) { 147 ServoPositionn = 180; 148 } 149 if (ServoPosition < 0) { 150 ServoPositionn 151 = 0; 152 } else { 153 ServoPositionn = ServoPosition; 154 } 155 156 // Update 157 the positon 158 Servo.write(ServoPositionn); 159 160 // Display 161 if 162 (0 <= ServoPosition && ServoPosition <= 180) { 163 lcd.setCursor(0, 0); 164 lcd.print(" 165 Degrees "); 166 lcd.setCursor(0, 1); 167 lcd.print(ServoPosition); 168 169 lcd.print("_______________"); 170 } 171 172 // Buzzer allarm and alert message 173 174 int buzzerTime = 70; 175 if (ServoPosition > 180) { 176 digitalWrite(buzzer,HIGH); 177 178 delay(buzzerTime); 179 digitalWrite(buzzer,LOW); 180 delay(buzzerTime); 181 182 lcd.setCursor(0, 0); 183 lcd.print("!!!!Error404!!!!"); 184 lcd.setCursor(0, 185 1); 186 lcd.print("!Invalid number!"); 187 } 188 189 // Set and apply the 190 update delay 191 int MainDelayyyy = 1; 192 delay(MainDelayyyy); 193}
IR SERVO
java
1/* 2 Controls: 3 * PAUSE to reset the number 4 * 0 to 9 keys to add a digit to the number 5 * Press or hold UP / DOWN to easly switch between different positions 6 7 Credits: 8 * Manauzzi Stefano (software) 9 * Scaldarella Francesco (hardware) 10*/ 11 12// Libraries 13#include <IRremote.h> 14#include <IRremoteInt.h> 15#include <Servo.h> 16#include <LiquidCrystal.h> 17 18// Pin you have to connect to 19int ServoPin = 8; 20int receiver = 11; 21int buzzer = 13; 22 23// Useful objects 24Servo Servo; 25IRrecv irrecv(receiver); 26decode_results results; 27 28// Initialize the display 29LiquidCrystal lcd(7, 6, 2, 3, 4, 5); 30 31// The starting position is 0 degrees. 32int ServoPosition = 0; 33int ServoPositionn = 0; 34 35// Main Function to transform the IR signal in an instruction 36int translateIR(int InitialServoPos) { 37 38 // Analise the received signal 39 switch(results.value) { 40 41 42 // Reset the number 43 case 0xFF02FD: return 0; break; 44 45 // All numbers (0-9) to set a specific degree position (0-90) 46 case 0xFF6897: return InitialServoPos * 10; break; 47 case 0xFF30CF: return InitialServoPos * 10 + 1; break; 48 case 0xFF18E7: return InitialServoPos * 10 + 2; break; 49 case 0xFF7A85: return InitialServoPos * 10 + 3; break; 50 case 0xFF10EF: return InitialServoPos * 10 + 4; break; 51 case 0xFF38C7: return InitialServoPos * 10 + 5; break; 52 case 0xFF5AA5: return InitialServoPos * 10 + 6; break; 53 case 0xFF42BD: return InitialServoPos * 10 + 7; break; 54 case 0xFF4AB5: return InitialServoPos * 10 + 8; break; 55 case 0xFF52AD: return InitialServoPos * 10 + 9; break; 56 57 // Change the position with UP / DOWN 58 case 0xFF906F: return InitialServoPos + 10; break; 59 case 0xFFE01F: return InitialServoPos - 10; break; 60 61 /* 62 // Repeat 63 case 0xFFFFFFFF: 64 // Augment the position 65 if (InitialServoPos % 10 == 1) { 66 return InitialServoPos + 10; 67 } 68 // Decrease the position 69 else if (InitialServoPos % 10 == 2) { 70 return InitialServoPos - 10; 71 } 72 break; 73 */ 74 } 75 76 77 // Don't over repeat with a secoundary background delay 78 int delayyy = 100; 79 delay(delayyy); 80} 81 82// *** Setup *** 83void setup() 84{ 85 // Start the Serial process 86 Serial.begin(9600); 87 88 // Set up the buzzer 89 pinMode(buzzer, OUTPUT); 90 91 // Set up the servo 92 Servo.attach(ServoPin); 93 94 // Set up the IR 95 irrecv.enableIRIn(); 96 97 // Initialize display LCD 98 lcd.begin(16,2); 99} 100 101// *** Main Loop *** 102void loop() { 103 104 // Receive the signal 105 if (irrecv.decode(&results)) { 106 ServoPosition = translateIR(ServoPosition); 107 irrecv.resume(); // receive the next value 108 } 109 110 // Position Adjustments 111 if (ServoPosition > 180) { 112 ServoPositionn = 180; 113 } 114 if (ServoPosition < 0) { 115 ServoPositionn = 0; 116 } else { 117 ServoPositionn = ServoPosition; 118 } 119 120 // Update the positon 121 Servo.write(ServoPositionn); 122 123 // Display 124 if (0 <= ServoPosition && ServoPosition <= 180) { 125 lcd.setCursor(0, 0); 126 lcd.print(" Degrees "); 127 lcd.setCursor(0, 1); 128 lcd.print(ServoPosition); 129 lcd.print("_______________"); 130 } 131 132 // Buzzer allarm and alert message 133 int buzzerTime = 70; 134 if (ServoPosition > 180) { 135 digitalWrite(buzzer,HIGH); 136 delay(buzzerTime); 137 digitalWrite(buzzer,LOW); 138 delay(buzzerTime); 139 lcd.setCursor(0, 0); 140 lcd.print("!!!!Error404!!!!"); 141 lcd.setCursor(0, 1); 142 lcd.print("!Invalid number!"); 143 } 144 145 // Set and apply the update delay 146 int MainDelayyyy = 1; 147 delay(MainDelayyyy); 148}
Downloadable files
IR SERVO
IR SERVO
IR SERVO
IR SERVO
Comments
Only logged in users can leave comments
razangry1731
0 Followers
•0 Projects
Table of contents
Intro
3
0