#include <Ethernet.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
#include <avr/pgmspace.h>
int SensorPin1 = A0; //analog pin 0
int SensorPin2 = A1; //analog pin 0
int SensorPin3 = A2; //analog pin 0
byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server_addr(***); // mysql 서버 주소를 입력
char user[] = "**"; // mysql user 입력
char password[] = "***"; // mysql password 입력
// Sample query
EthernetClient client;
MySQL_Connection conn((Client *)&client);
void setup() {
Serial.begin(9600);
while (!Serial); // wait for serial port to connect
Ethernet.begin(mac_addr);
Serial.println("Connecting...");
if (conn.connect(server_addr, 3306, user, password)) {
delay(1000);
}
else
Serial.println("Connection failed.");
}
void loop() {
delay(2000);
int SensorReading1 = analogRead(SensorPin1);
int SensorReading2 = analogRead(SensorPin2);
int SensorReading3 = analogRead(SensorPin3);
int mfsr_r18 = map(SensorReading1, 0, 1024, 0, 255);
if ( mfsr_r18 >= 1 )
{
const PROGMEM char UPDATE_SQL[] = "UPDATE userdb.ParkingLotSpace set is_park='1' where P_number = 'park101' and Reserv != '1'" ;
Serial.println("Recording data.");
MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
cur_mem->execute(UPDATE_SQL);
delete cur_mem;
}
else
{
const PROGMEM char UPDATE_SQL[] = "UPDATE userdb.ParkingLotSpace set is_park='0' where P_number = 'park101'and Reserv != '1'";
Serial.println("Recording data.");
MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
cur_mem->execute(UPDATE_SQL);
delete cur_mem;
}
int mfsr_r19 = map(SensorReading2, 0, 1024, 0, 255);
if ( mfsr_r19 >= 1 )
{
const PROGMEM char UPDATE_SQL[] = "UPDATE userdb.ParkingLotSpace set is_park='1' where P_number = 'park102'and Reserv != '1'";
Serial.println("Recording data.");
MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
cur_mem->execute(UPDATE_SQL);
delete cur_mem;
}
else
{
const PROGMEM char UPDATE_SQL[] = "UPDATE userdb.ParkingLotSpace set is_park='0' where P_number = 'park102'and Reserv != '1'";
Serial.println("Recording data.");
MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
cur_mem->execute(UPDATE_SQL);
delete cur_mem;
}
int mfsr_r20 = map(SensorReading3, 0, 1024, 0, 255);
if ( mfsr_r20 >= 1 )
{
const PROGMEM char UPDATE_SQL[] = "UPDATE userdb.ParkingLotSpace set is_park='1' where P_number = 'park103'and Reserv != '1'";
Serial.println("Recording data.");
MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
cur_mem->execute(UPDATE_SQL);
delete cur_mem;
}
else
{
const PROGMEM char UPDATE_SQL[] = "UPDATE userdb.ParkingLotSpace set is_park='0' where P_number = 'park103'and Reserv != '1'";
Serial.println("Recording data.");
MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
cur_mem->execute(UPDATE_SQL);
delete cur_mem;
}
Serial.println(mfsr_r18);
Serial.println(mfsr_r19);
Serial.println(mfsr_r20);
}
I want to store the parkempty value of park1 in the variable 'A' in Arduino, what should I do?