Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <mysql.h>
- int sensorPin = A0; // select the input pin for the potentiometer
- int ledPin = 13; // select the pin for the LED
- int sensorValue = 0; // variable to store the value coming from the sensor
- void setup() {
- // declare the ledPin as an OUTPUT:
- pinMode(ledPin, OUTPUT);
- }
- void loop() {
- // read the value from the sensor:
- sensorValue = analogRead(sensorPin);
- // turn the ledPin on
- digitalWrite(ledPin, HIGH);
- // stop the program for <sensorValue> milliseconds:
- delay(sensorValue);
- // turn the ledPin off:
- digitalWrite(ledPin, LOW);
- // stop the program for for <sensorValue> milliseconds:
- delay(sensorValue);
- MYSQL *conn;
- MYSQL_RES *result;
- MYSQL_ROW row;
- const char* host = "192.168.1.185"; // host
- const char* database = "dbprova"; // database
- const char* db_user = "root"; // nome utente
- const char* db_pass = "endek"; // password
- int main (int argc, char *argv[])
- {
- conn = mysql_init (NULL);
- mysql_real_connect (conn, /* connection handler */
- host, /* host */
- db_user, /* user name */
- db_pass, /* password */
- database, /* database */
- 0, /* porta */
- NULL, /* socket */
- 0); /* flags */
- mysql_query(conn, "INSERT INTO TABLE1 VAL1=(sensorValue)");
- result = mysql_use_result(conn);
- mysql_close (conn);
- exit (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement