-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuperpower.pde
119 lines (108 loc) · 2.48 KB
/
superpower.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include "QuectelM10.h"
#include <NewSoftSerial.h>
#include "inetGSM.h"
/*#include "LOG.h"
#define __LOG_LEVEL 5
LOG logme(__LOG_LEVEL);
*/
/*
* We should put here some copyright stuff.
*
* This program is developed just to test-develop the Arduino-TID-GSM libraries.
*/
InetGSM inet;
char response[200];
char* separator="#";
int numdata;
const int btnR = 4; // the number of the pushbutton pin
const int btnU = 5;
const int btnL = 6;
const int ledPin = 13; // the number of the LED pin
const int motorPinR = 9;
const int motorPinL= 10;
const int palaPin= 11;
void setup()
{
delay(5000);
pinMode(ledPin, OUTPUT);
pinMode(motorPinR, OUTPUT);
pinMode(motorPinL, OUTPUT);
pinMode(palaPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(btnR, INPUT);
pinMode(btnU, INPUT);
pinMode(btnL, INPUT);
//Serial connection.
Serial.begin(9600);
Serial.println("GSM Shield testing. Start the modem");
delay(1000);
if (gsm.begin())
Serial.println("\nstatus=READY");
else Serial.println("\nstatus=IDLE");
if (gsm.attachGPRS("movistar.es", "movistar", "movistar"))
Serial.println("\nstatus=ATTACHED");
else Serial.println("\nstatus=ERROR");
Serial.println("Initialized");
};
void loop()
{
char command=' ';
char* ptr;
int sequeda=1;
// inet.httpGET("www.google.com",80,"/", response, 200);
inet.httpGET("217.124.215.168",80,"/cgi-bin/superpower.py", response, 200);
ptr=strtok(response, separator);
ptr=strtok(NULL, separator);
Serial.print("Respuesta:");
Serial.println(response);
if(ptr!=0)
{
command=*ptr;
Serial.println(command);
}
if (command == 'w') {
// turn LED on:
digitalWrite(ledPin, HIGH);
analogWrite(motorPinR, 250);
analogWrite(motorPinL,250);
sequeda=0;
}
else if (command == 'd'){
// turn LED off:
digitalWrite(ledPin, HIGH);
analogWrite(motorPinR, 0);
analogWrite(motorPinL, 250);
sequeda=0;
}
else if (command == 'a'){
// turn LED off:
digitalWrite(ledPin, HIGH);
analogWrite(motorPinL, 0);
analogWrite(motorPinR, 250);
sequeda=0;
}
else if (command == 's'){
//mueve pala
digitalWrite(palaPin,HIGH);
delay(1500);
digitalWrite(palaPin,LOW);
sequeda=0;
}
else{
// turn LED off:
digitalWrite(ledPin, LOW);
analogWrite(motorPinL, 0);
analogWrite(motorPinR, 0);
}
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
if(sequeda){
digitalWrite(ledPin, HIGH);
delay(200);
} else {
digitalWrite(ledPin, LOW);
delay(200);
}
};