Components and supplies
Jumper wires (generic)
Tinkerkit Text LCD 16x02
LED (generic)
Arduino UNO
Arduino GSM Shield (integrated antenna)
NeoPixel Ring: WS2812 5050 RGB LED
TinkerKit Rotary Potentiometer
Apps and platforms
Arduino IDE
Project description
Code
Code snippet #3
arduino
1void loop() { 2 lastMess = ""; 3 //reading messages 4 if (sms.available()) // if there are SMS on the SIM card 5 { 6 x++; //message counter adds one 7 sms.remoteNumber(remoteNumber, 20); 8 9 //Show the message on monitor 10 Serial.println("Messages received from"); 11 Serial.println(remoteNumber); //Prints senders number on the serial monitor 12 Serial.println("Message:"); 13 14 //Code for the LCD screen, comment out or remove if note used. 15 //Show the message on LCD 16 lcd.clear(); 17 lcd.setCursor(0,0); 18 lcd.print(remoteNumber); 19 lcd.setCursor(0,1); 20 lcd.print("Message: "); 21 lcd.setCursor(11,1); 22 23 m = sms.peek(); //sms.peek looks up the first byte in the messages. 24 //By storing it in the global char variable m, it is possible to use it later for the swich-case function 25 26 27 while(c=sms.read()) { 28 String nextChar = String (c); 29 String Mess = (lastMess + nextChar); 30 lastMess = Mess; 31 /*sms.read collects one digit of the messages at time and stores it in the variable c. 32 This while loop builds a String variable "lastMess" from each byte in the messages for displaying. 33 */ 34 } 35 36 Serial.println(lastMess); // prints the whole messages on the monitor and LCD screen 37 lcd.print(lastMess); 38 39 40 switch (m){ //Checks the value of the variable m where the sketch has stored the first letter of the SMS. Runs the case according to the value. 41 42 case 'R': //sets the lights to red with the function eittiEinu 43 oneByOne(LED.Color(0, 255, 0), 50); // the parameters of the function are two, the strip color, and the delay time in milliseconds for each pixel 44 countR = countR++; 45 Serial.print(countR); 46 delay(5000); // Sets a delay time in milliseconds. The loop will not search for a new SMS untill this time is out 47 break; 48 49 case 'Z': // turn off the lights 50 oneByOne(LED.Color(0, 0, 0), 50); 51 delay(5000); 52 break; 53 54 case 'Q': // If you send the letter Q as SMS, you will recieve an SMS in return indicating the number of SMSÃ
Code snippet #1
arduino
1#include <Adafruit_NeoPixel.h> // This includes Pixel library from ADAFRUIT. Awailable here https://github.com/adafruit/Adafruit_NeoPixel 2#include <GSM.h> // This includes the GSM library, included in your Arduino IDE 3#include <LiquidCrystal.h> // This includes the LCD library, included in your Arduino IDE 4 5#define PINNUMBER "" // declaration of the constant PINNUMBER used to push the pin number of the SIM card 6#define PIN 6 // declaration of the constant PIN, and setting it to output nr. 6 7LiquidCrystal lcd(12, 11, 9, 8, 5, 4); // sets the pinnumbers used for the LCD display. Comment out if no LCD 8 9Adafruit_NeoPixel LED = Adafruit_NeoPixel(150, PIN, NEO_GRB + NEO_KHZ400); 10/* This sets values to the variables in the NeoPixel class function. 11First variable is the number of lights, 12then it is the output, previously defined as nr.6 13Next variable sets how the pixels are wired 14 NEO_GRB is for GRB bitstream (Green, Red, Blue) most neopixels 15 NEO_RGB is for RGB bitstream (Red, Green, Blue) 16Finally it addresses the frequency of the bitstream 17 NEO_KHZ800 for 800 KHz bitstream 18 NEO_KHZ400 for 400 KHz bitstream 19*/ 20 21 22GSM gsmAccess; // opens up GSM access on the shield. 23GSM_SMS sms; 24 25char remoteNumber[20]; // Variable to store the remote number from the modem. 26char c; //Variable for reading the sms messages from the SIM card 27char m; //Variable for storing the first letter in each messages 28int x=0; //Counter for the number of SMS messages processed 29char lastm; //Variable to stop SMS replying 30String lastMess; //for storing the whole message 31int countR, countG, countB, countY, countW, countP, countO; //Counters for keeping information on how often each class is called 32
Github
https://github.com/adafruit/Adafruit_NeoPixel
Github
https://github.com/adafruit/Adafruit_NeoPixel
Code snippet #5
arduino
1/* 2***** SHINE ON YOU (Crazy Diamond) ***** https://www.youtube.com/watch?v=R0sw2CgysWY 3 4GSM 5 interface of LED/GSM lightpost. 6Designed and written for the annual meeting 7 of Innovation Center of Iceland in February 2014. 8 9This sketch makes it possible 10 to control the color of digital RGB LED light pixels with SMS messages. It can easily 11 be manipulated to control 12relays, motors or other outputs of your choice. The 13 idea behind this project is to make outdoor lightning interactive. This can be useful 14 for example to 15light up your driveway as you drive home from work or even to 16 remotely light up your house to repell burglars when you are on holiday. This can 17 also be used 18for setting up charging posts for electric cars, where the user 19 signs up with his GSM phone to activate the charging and gets the bill asigned to 20 his GSM account. 21 22Created by; Thorsteinn Tomas Broddason, Fab Lab Saudarkrokur 23 24 25***** 26 The circuit ***** 27For this project you need; 28*Arduino Uno 29*Arduino GSM 30 shield 31*LCD 16x2 display, 32*WS2801 LED pixels connected to PIN 6 33*Potentio 34 meter 35*5V Power source for the LED string 36*12V Power source for the UNO and 37 GSM shield 38 39Connect the LED pixels to ground on the Arduino board and the 40 data cable of the pixels to pin 6. Wire the LCD screen to the board as explained 41 here: 42LCD RS pin to digital pin 12 43LCD Enable pin to digital pin 11 44LCD 45 D4 pin to digital pin 9 46LCD D5 pin to digital pin 8 47LCD D6 pin to digital 48 pin 5 49LCD D7 pin to digital pin 4 50 51Wire a 10K pot to +5V and GND, with 52 it's output to LCD screen's VO pin (pin3). 53Schematics for the circuit awailable 54 at www.fablab.is. 55*/ 56 57// **** 1 Libraries, definitions and global variables 58 **** 59 60#include <Adafruit_NeoPixel.h> // This includes Pixel library from ADAFRUIT. 61 Awailable here https://github.com/adafruit/Adafruit_NeoPixel 62#include <GSM.h> 63 // This includes the GSM library, included in your Arduino IDE 64#include <LiquidCrystal.h> 65 // This includes the LCD library, included in your Arduino IDE 66 67#define PINNUMBER 68 "" // declaration of the constant PINNUMBER used to push the pin number of the 69 SIM card 70#define PIN 6 // declaration of the constant PIN, and setting it to 71 output nr. 6 72LiquidCrystal lcd(12, 11, 9, 8, 5, 4); // sets the pinnumbers used 73 for the LCD display. Comment out if no LCD 74 75Adafruit_NeoPixel LED = Adafruit_NeoPixel(150, 76 PIN, NEO_GRB + NEO_KHZ400); 77/* This sets values to the variables in the NeoPixel 78 class function. 79First variable is the number of lights, 80then it is the output, 81 previously defined as nr.6 82Next variable sets how the pixels are wired 83 NEO_GRB 84 is for GRB bitstream (Green, Red, Blue) most neopixels 85 NEO_RGB is for RGB bitstream 86 (Red, Green, Blue) 87Finally it addresses the frequency of the bitstream 88 NEO_KHZ800 89 for 800 KHz bitstream 90 NEO_KHZ400 for 400 KHz bitstream 91*/ 92 93 94GSM 95 gsmAccess; // opens up GSM access on the shield. 96GSM_SMS sms; 97 98char remoteNumber[20]; 99 // Variable to store the remote number from the modem. 100char c; //Variable for 101 reading the sms messages from the SIM card 102char m; //Variable for storing the 103 first letter in each messages 104int x=0; //Counter for the number of SMS messages 105 processed 106char lastm; //Variable to stop SMS replying 107String lastMess; //for 108 storing the whole message 109int countR, countG, countB, countY, countW, countP, 110 countO; //Counters for keeping information on how often each class is called 111 112 113// 114 **** 2 Setup **** 115 116void setup() { 117 //Setup for SMS recieving. Serial setup 118 makes it possible to monitor the status on your PC while connected 119 Serial.begin(9600); 120 121 Serial.println("SMS Recieving"); 122 123 // LCD setup is for the LCD screen. 124 Comment it out if you dont set it up. 125 lcd.begin(16, 2); 126 lcd.print("SMS 127 recieve"); 128 129 boolean notConnected = true; // this defines a variable that 130 indicates no GSM connection if true 131 while(notConnected) { // if there is no 132 connection, the program runs gsmAcess. gsmAcess returns GSM_READY when connected 133 134 if(gsmAccess.begin(PINNUMBER)==GSM_READY) // If you have a PIN number on your 135 SIM card, write it as parameters here in quotes. PINNUMBER"9876" 136 notConnected 137 = false; 138 else { 139 //messages printed on the serial monitor or LCD 140 screen, then it tries again in 1000 milliseconds 141 Serial.println("No connection"); 142 143 144 //Code for the LCD screen, comment out or remove if note used. 145 lcd.setCursor(0, 146 1); 147 lcd.print("No connection"); 148 149 delay(1000); 150 } 151 152 } 153 // if connection is established 154 Serial.println("GSM connected"); 155 //GSM connected 156 Serial.println("Waiting"); //Waiting for SMS 157 158 //Code 159 for the LCD screen, comment out or remove if note used. 160 lcd.clear(); 161 lcd.print("GSM 162 connected"); 163 lcd.setCursor(0,1); 164 lcd.print("Waiting"); 165 166 //Setup 167 for the lights 168 169 LED.begin(); 170 LED.show(); 171} 172 173// **** 3 The 174 loop **** 175 176void loop() { 177 lastMess = ""; 178 //reading messages 179 180 if (sms.available()) // if there are SMS on the SIM card 181 { 182 x++; //message 183 counter adds one 184 sms.remoteNumber(remoteNumber, 20); 185 186 //Show 187 the message on monitor 188 Serial.println("Messages received from"); 189 Serial.println(remoteNumber); 190 //Prints senders number on the serial monitor 191 Serial.println("Message:"); 192 193 194 //Code for the LCD screen, comment out or remove if note used. 195 //Show the 196 message on LCD 197 lcd.clear(); 198 lcd.setCursor(0,0); 199 lcd.print(remoteNumber); 200 201 lcd.setCursor(0,1); 202 lcd.print("Message: "); 203 lcd.setCursor(11,1); 204 205 206 m = sms.peek(); //sms.peek looks up the first byte in the messages. 207 208 //By storing it in the global char variable m, it is possible to use it 209 later for the swich-case function 210 211 212 while(c=sms.read()) { 213 String 214 nextChar = String (c); 215 String Mess = (lastMess + nextChar); 216 lastMess 217 = Mess; 218 /*sms.read collects one digit of the messages at time and stores 219 it in the variable c. 220 This while loop builds a String variable "lastMess" 221 from each byte in the messages for displaying. 222 */ 223 } 224 225 226 Serial.println(lastMess); // prints the whole messages on the monitor and LCD 227 screen 228 lcd.print(lastMess); 229 230 231 switch (m){ //Checks the value 232 of the variable m where the sketch has stored the first letter of the SMS. Runs 233 the case according to the value. 234 235 case 'R': //sets the lights 236 to red with the function eittiEinu 237 oneByOne(LED.Color(0, 255, 0), 50); 238 // the parameters of the function are two, the strip color, and the delay time in 239 milliseconds for each pixel 240 countR = countR++; 241 Serial.print(countR); 242 243 delay(5000); // Sets a delay time in milliseconds. The loop will not search 244 for a new SMS untill this time is out 245 break; 246 247 case 'Y': 248 //"Yellow" 249 oneByOne(LED.Color(255, 255, 0), 50); 250 countY 251 = countY++; 252 Serial.print(countY); 253 delay(5000); 254 break; 255 256 257 case 'G': //"Green" 258 oneByOne(LED.Color(255, 0, 0), 259 50); 260 countG = countG++; 261 Serial.print(countG); 262 delay(5000); 263 264 break; 265 266 case 'B': //"Blue" 267 oneByOne(LED.Color(0, 268 0, 255), 50); 269 countB = countB++; 270 Serial.print(countB); 271 272 delay(5000); 273 break; 274 275 case 'W': // "White" 276 277 oneByOne(LED.Color(255, 255, 255), 50); 278 countW = countW++; 279 280 Serial.print(countW); 281 delay(5000); 282 break; 283 284 285 case 'P': // "Pink" 286 oneByOne(LED.Color(20, 255, 147), 50); 287 288 countP = countP++; 289 Serial.print(countP); 290 delay(5000); 291 292 break; 293 294 case 'O': //"Orange" 295 oneByOne(LED.Color(80, 296 255, 0), 50); 297 countO = countO++; 298 Serial.print(countO); 299 300 delay(5000); 301 break; 302 303 case 'Z': // turn off 304 the lights 305 oneByOne(LED.Color(0, 0, 0), 50); 306 delay(5000); 307 308 break; 309 310 case 'Q': // If you send the letter Q as SMS, 311 you will recieve an SMS in return indicating the number of SMSÃ
Code snippet #2
arduino
1void setup() { 2 //Setup for SMS recieving. Serial setup makes it possible 3 to monitor the status on your PC while connected 4 Serial.begin(9600); 5 Serial.println("SMS 6 Recieving"); 7 8 // LCD setup is for the LCD screen. Comment it out if you 9 dont set it up. 10 lcd.begin(16, 2); 11 lcd.print("SMS recieve"); 12 13 14 boolean notConnected = true; // this defines a variable that indicates no GSM 15 connection if true 16 while(notConnected) { // if there is no connection, the 17 program runs gsmAcess. gsmAcess returns GSM_READY when connected 18 if(gsmAccess.begin(PINNUMBER)==GSM_READY) 19 // If you have a PIN number on your SIM card, write it as parameters here in quotes. 20 PINNUMBER"9876" 21 notConnected = false; 22 else { 23 //messages 24 printed on the serial monitor or LCD screen, then it tries again in 1000 milliseconds 25 26 Serial.println("No connection"); 27 28 //Code for the LCD screen, comment 29 out or remove if note used. 30 lcd.setCursor(0, 1); 31 lcd.print("No 32 connection"); 33 34 delay(1000); 35 } 36 } 37 // if connection 38 is established 39 Serial.println("GSM connected"); //GSM connected 40 Serial.println("Waiting"); 41 //Waiting for SMS 42 43 //Code for the LCD screen, comment out or remove if 44 note used. 45 lcd.clear(); 46 lcd.print("GSM connected"); 47 lcd.setCursor(0,1); 48 49 lcd.print("Waiting"); 50 51 //Setup for the lights 52 53 LED.begin(); 54 55 LED.show(); 56} 57
Code snippet #3
arduino
1void loop() { 2 lastMess = ""; 3 //reading messages 4 if (sms.available()) // if there are SMS on the SIM card 5 { 6 x++; //message counter adds one 7 sms.remoteNumber(remoteNumber, 20); 8 9 //Show the message on monitor 10 Serial.println("Messages received from"); 11 Serial.println(remoteNumber); //Prints senders number on the serial monitor 12 Serial.println("Message:"); 13 14 //Code for the LCD screen, comment out or remove if note used. 15 //Show the message on LCD 16 lcd.clear(); 17 lcd.setCursor(0,0); 18 lcd.print(remoteNumber); 19 lcd.setCursor(0,1); 20 lcd.print("Message: "); 21 lcd.setCursor(11,1); 22 23 m = sms.peek(); //sms.peek looks up the first byte in the messages. 24 //By storing it in the global char variable m, it is possible to use it later for the swich-case function 25 26 27 while(c=sms.read()) { 28 String nextChar = String (c); 29 String Mess = (lastMess + nextChar); 30 lastMess = Mess; 31 /*sms.read collects one digit of the messages at time and stores it in the variable c. 32 This while loop builds a String variable "lastMess" from each byte in the messages for displaying. 33 */ 34 } 35 36 Serial.println(lastMess); // prints the whole messages on the monitor and LCD screen 37 lcd.print(lastMess); 38 39 40 switch (m){ //Checks the value of the variable m where the sketch has stored the first letter of the SMS. Runs the case according to the value. 41 42 case 'R': //sets the lights to red with the function eittiEinu 43 oneByOne(LED.Color(0, 255, 0), 50); // the parameters of the function are two, the strip color, and the delay time in milliseconds for each pixel 44 countR = countR++; 45 Serial.print(countR); 46 delay(5000); // Sets a delay time in milliseconds. The loop will not search for a new SMS untill this time is out 47 break; 48 49 case 'Z': // turn off the lights 50 oneByOne(LED.Color(0, 0, 0), 50); 51 delay(5000); 52 break; 53 54 case 'Q': // If you send the letter Q as SMS, you will recieve an SMS in return indicating the number of SMSÃ
Code snippet #5
arduino
1/* 2***** SHINE ON YOU (Crazy Diamond) ***** https://www.youtube.com/watch?v=R0sw2CgysWY 3 4GSM interface of LED/GSM lightpost. 5Designed and written for the annual meeting of Innovation Center of Iceland in February 2014. 6 7This sketch makes it possible to control the color of digital RGB LED light pixels with SMS messages. It can easily be manipulated to control 8relays, motors or other outputs of your choice. The idea behind this project is to make outdoor lightning interactive. This can be useful for example to 9light up your driveway as you drive home from work or even to remotely light up your house to repell burglars when you are on holiday. This can also be used 10for setting up charging posts for electric cars, where the user signs up with his GSM phone to activate the charging and gets the bill asigned to his GSM account. 11 12Created by; Thorsteinn Tomas Broddason, Fab Lab Saudarkrokur 13 14 15***** The circuit ***** 16For this project you need; 17*Arduino Uno 18*Arduino GSM shield 19*LCD 16x2 display, 20*WS2801 LED pixels connected to PIN 6 21*Potentio meter 22*5V Power source for the LED string 23*12V Power source for the UNO and GSM shield 24 25Connect the LED pixels to ground on the Arduino board and the data cable of the pixels to pin 6. Wire the LCD screen to the board as explained here: 26LCD RS pin to digital pin 12 27LCD Enable pin to digital pin 11 28LCD D4 pin to digital pin 9 29LCD D5 pin to digital pin 8 30LCD D6 pin to digital pin 5 31LCD D7 pin to digital pin 4 32 33Wire a 10K pot to +5V and GND, with it's output to LCD screen's VO pin (pin3). 34Schematics for the circuit awailable at www.fablab.is. 35*/ 36 37// **** 1 Libraries, definitions and global variables **** 38 39#include <Adafruit_NeoPixel.h> // This includes Pixel library from ADAFRUIT. Awailable here https://github.com/adafruit/Adafruit_NeoPixel 40#include <GSM.h> // This includes the GSM library, included in your Arduino IDE 41#include <LiquidCrystal.h> // This includes the LCD library, included in your Arduino IDE 42 43#define PINNUMBER "" // declaration of the constant PINNUMBER used to push the pin number of the SIM card 44#define PIN 6 // declaration of the constant PIN, and setting it to output nr. 6 45LiquidCrystal lcd(12, 11, 9, 8, 5, 4); // sets the pinnumbers used for the LCD display. Comment out if no LCD 46 47Adafruit_NeoPixel LED = Adafruit_NeoPixel(150, PIN, NEO_GRB + NEO_KHZ400); 48/* This sets values to the variables in the NeoPixel class function. 49First variable is the number of lights, 50then it is the output, previously defined as nr.6 51Next variable sets how the pixels are wired 52 NEO_GRB is for GRB bitstream (Green, Red, Blue) most neopixels 53 NEO_RGB is for RGB bitstream (Red, Green, Blue) 54Finally it addresses the frequency of the bitstream 55 NEO_KHZ800 for 800 KHz bitstream 56 NEO_KHZ400 for 400 KHz bitstream 57*/ 58 59 60GSM gsmAccess; // opens up GSM access on the shield. 61GSM_SMS sms; 62 63char remoteNumber[20]; // Variable to store the remote number from the modem. 64char c; //Variable for reading the sms messages from the SIM card 65char m; //Variable for storing the first letter in each messages 66int x=0; //Counter for the number of SMS messages processed 67char lastm; //Variable to stop SMS replying 68String lastMess; //for storing the whole message 69int countR, countG, countB, countY, countW, countP, countO; //Counters for keeping information on how often each class is called 70 71 72// **** 2 Setup **** 73 74void setup() { 75 //Setup for SMS recieving. Serial setup makes it possible to monitor the status on your PC while connected 76 Serial.begin(9600); 77 Serial.println("SMS Recieving"); 78 79 // LCD setup is for the LCD screen. Comment it out if you dont set it up. 80 lcd.begin(16, 2); 81 lcd.print("SMS recieve"); 82 83 boolean notConnected = true; // this defines a variable that indicates no GSM connection if true 84 while(notConnected) { // if there is no connection, the program runs gsmAcess. gsmAcess returns GSM_READY when connected 85 if(gsmAccess.begin(PINNUMBER)==GSM_READY) // If you have a PIN number on your SIM card, write it as parameters here in quotes. PINNUMBER"9876" 86 notConnected = false; 87 else { 88 //messages printed on the serial monitor or LCD screen, then it tries again in 1000 milliseconds 89 Serial.println("No connection"); 90 91 //Code for the LCD screen, comment out or remove if note used. 92 lcd.setCursor(0, 1); 93 lcd.print("No connection"); 94 95 delay(1000); 96 } 97 } 98 // if connection is established 99 Serial.println("GSM connected"); //GSM connected 100 Serial.println("Waiting"); //Waiting for SMS 101 102 //Code for the LCD screen, comment out or remove if note used. 103 lcd.clear(); 104 lcd.print("GSM connected"); 105 lcd.setCursor(0,1); 106 lcd.print("Waiting"); 107 108 //Setup for the lights 109 110 LED.begin(); 111 LED.show(); 112} 113 114// **** 3 The loop **** 115 116void loop() { 117 lastMess = ""; 118 //reading messages 119 if (sms.available()) // if there are SMS on the SIM card 120 { 121 x++; //message counter adds one 122 sms.remoteNumber(remoteNumber, 20); 123 124 //Show the message on monitor 125 Serial.println("Messages received from"); 126 Serial.println(remoteNumber); //Prints senders number on the serial monitor 127 Serial.println("Message:"); 128 129 //Code for the LCD screen, comment out or remove if note used. 130 //Show the message on LCD 131 lcd.clear(); 132 lcd.setCursor(0,0); 133 lcd.print(remoteNumber); 134 lcd.setCursor(0,1); 135 lcd.print("Message: "); 136 lcd.setCursor(11,1); 137 138 m = sms.peek(); //sms.peek looks up the first byte in the messages. 139 //By storing it in the global char variable m, it is possible to use it later for the swich-case function 140 141 142 while(c=sms.read()) { 143 String nextChar = String (c); 144 String Mess = (lastMess + nextChar); 145 lastMess = Mess; 146 /*sms.read collects one digit of the messages at time and stores it in the variable c. 147 This while loop builds a String variable "lastMess" from each byte in the messages for displaying. 148 */ 149 } 150 151 Serial.println(lastMess); // prints the whole messages on the monitor and LCD screen 152 lcd.print(lastMess); 153 154 155 switch (m){ //Checks the value of the variable m where the sketch has stored the first letter of the SMS. Runs the case according to the value. 156 157 case 'R': //sets the lights to red with the function eittiEinu 158 oneByOne(LED.Color(0, 255, 0), 50); // the parameters of the function are two, the strip color, and the delay time in milliseconds for each pixel 159 countR = countR++; 160 Serial.print(countR); 161 delay(5000); // Sets a delay time in milliseconds. The loop will not search for a new SMS untill this time is out 162 break; 163 164 case 'Y': //"Yellow" 165 oneByOne(LED.Color(255, 255, 0), 50); 166 countY = countY++; 167 Serial.print(countY); 168 delay(5000); 169 break; 170 171 case 'G': //"Green" 172 oneByOne(LED.Color(255, 0, 0), 50); 173 countG = countG++; 174 Serial.print(countG); 175 delay(5000); 176 break; 177 178 case 'B': //"Blue" 179 oneByOne(LED.Color(0, 0, 255), 50); 180 countB = countB++; 181 Serial.print(countB); 182 delay(5000); 183 break; 184 185 case 'W': // "White" 186 oneByOne(LED.Color(255, 255, 255), 50); 187 countW = countW++; 188 Serial.print(countW); 189 delay(5000); 190 break; 191 192 case 'P': // "Pink" 193 oneByOne(LED.Color(20, 255, 147), 50); 194 countP = countP++; 195 Serial.print(countP); 196 delay(5000); 197 break; 198 199 case 'O': //"Orange" 200 oneByOne(LED.Color(80, 255, 0), 50); 201 countO = countO++; 202 Serial.print(countO); 203 delay(5000); 204 break; 205 206 case 'Z': // turn off the lights 207 oneByOne(LED.Color(0, 0, 0), 50); 208 delay(5000); 209 break; 210 211 case 'Q': // If you send the letter Q as SMS, you will recieve an SMS in return indicating the number of SMSÃ
Code snippet #1
arduino
1#include <Adafruit_NeoPixel.h> // This includes Pixel library from ADAFRUIT. Awailable here https://github.com/adafruit/Adafruit_NeoPixel 2#include <GSM.h> // This includes the GSM library, included in your Arduino IDE 3#include <LiquidCrystal.h> // This includes the LCD library, included in your Arduino IDE 4 5#define PINNUMBER "" // declaration of the constant PINNUMBER used to push the pin number of the SIM card 6#define PIN 6 // declaration of the constant PIN, and setting it to output nr. 6 7LiquidCrystal lcd(12, 11, 9, 8, 5, 4); // sets the pinnumbers used for the LCD display. Comment out if no LCD 8 9Adafruit_NeoPixel LED = Adafruit_NeoPixel(150, PIN, NEO_GRB + NEO_KHZ400); 10/* This sets values to the variables in the NeoPixel class function. 11First variable is the number of lights, 12then it is the output, previously defined as nr.6 13Next variable sets how the pixels are wired 14 NEO_GRB is for GRB bitstream (Green, Red, Blue) most neopixels 15 NEO_RGB is for RGB bitstream (Red, Green, Blue) 16Finally it addresses the frequency of the bitstream 17 NEO_KHZ800 for 800 KHz bitstream 18 NEO_KHZ400 for 400 KHz bitstream 19*/ 20 21 22GSM gsmAccess; // opens up GSM access on the shield. 23GSM_SMS sms; 24 25char remoteNumber[20]; // Variable to store the remote number from the modem. 26char c; //Variable for reading the sms messages from the SIM card 27char m; //Variable for storing the first letter in each messages 28int x=0; //Counter for the number of SMS messages processed 29char lastm; //Variable to stop SMS replying 30String lastMess; //for storing the whole message 31int countR, countG, countB, countY, countW, countP, countO; //Counters for keeping information on how often each class is called 32
Code snippet #2
arduino
1void setup() { 2 //Setup for SMS recieving. Serial setup makes it possible to monitor the status on your PC while connected 3 Serial.begin(9600); 4 Serial.println("SMS Recieving"); 5 6 // LCD setup is for the LCD screen. Comment it out if you dont set it up. 7 lcd.begin(16, 2); 8 lcd.print("SMS recieve"); 9 10 boolean notConnected = true; // this defines a variable that indicates no GSM connection if true 11 while(notConnected) { // if there is no connection, the program runs gsmAcess. gsmAcess returns GSM_READY when connected 12 if(gsmAccess.begin(PINNUMBER)==GSM_READY) // If you have a PIN number on your SIM card, write it as parameters here in quotes. PINNUMBER"9876" 13 notConnected = false; 14 else { 15 //messages printed on the serial monitor or LCD screen, then it tries again in 1000 milliseconds 16 Serial.println("No connection"); 17 18 //Code for the LCD screen, comment out or remove if note used. 19 lcd.setCursor(0, 1); 20 lcd.print("No connection"); 21 22 delay(1000); 23 } 24 } 25 // if connection is established 26 Serial.println("GSM connected"); //GSM connected 27 Serial.println("Waiting"); //Waiting for SMS 28 29 //Code for the LCD screen, comment out or remove if note used. 30 lcd.clear(); 31 lcd.print("GSM connected"); 32 lcd.setCursor(0,1); 33 lcd.print("Waiting"); 34 35 //Setup for the lights 36 37 LED.begin(); 38 LED.show(); 39} 40
Code snippet #4
arduino
1void oneByOne(uint32_t l, uint8_t bid) { 2 3 if (m != lastm) 4 { 5 sms.beginSMS(remoteNumber); 6 String Reply ="Thank you for your message : " + lastMess; 7 sms.print(Reply); 8 sms.endSMS(); 9 } 10 11 for(uint16_t i=0; i<LED.numPixels(); i++) { 12 LED.setPixelColor(i, l); 13 LED.show(); 14 delay(bid); 15 }//end for 16 17 sms.flush(); //discards the SMS message 18 lastm=m; 19}
Comments
Only logged in users can leave comments
Arduino_Scuola
0 Followers
•0 Projects
Table of contents
Intro
7
0