Advertisement
Guest User

Untitled

a guest
Aug 8th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <mysql.h>
  3.  
  4. int sensorPin = A0; // select the input pin for the potentiometer
  5. int ledPin = 13; // select the pin for the LED
  6. int sensorValue = 0; // variable to store the value coming from the sensor
  7.  
  8. void setup() {
  9. // declare the ledPin as an OUTPUT:
  10. pinMode(ledPin, OUTPUT);
  11. }
  12.  
  13. void loop() {
  14. // read the value from the sensor:
  15. sensorValue = analogRead(sensorPin);
  16. // turn the ledPin on
  17. digitalWrite(ledPin, HIGH);
  18. // stop the program for <sensorValue> milliseconds:
  19. delay(sensorValue);
  20. // turn the ledPin off:
  21. digitalWrite(ledPin, LOW);
  22. // stop the program for for <sensorValue> milliseconds:
  23. delay(sensorValue);
  24.  
  25. MYSQL *conn;
  26. MYSQL_RES *result;
  27. MYSQL_ROW row;
  28.  
  29. const char* host = "192.168.1.185"; // host
  30. const char* database = "dbprova"; // database
  31. const char* db_user = "root"; // nome utente
  32. const char* db_pass = "endek"; // password
  33.  
  34. int main (int argc, char *argv[])
  35. {
  36. conn = mysql_init (NULL);
  37. mysql_real_connect (conn, /* connection handler */
  38. host, /* host */
  39. db_user, /* user name */
  40. db_pass, /* password */
  41. database, /* database */
  42. 0, /* porta */
  43. NULL, /* socket */
  44. 0); /* flags */
  45.  
  46. mysql_query(conn, "INSERT INTO TABLE1 VAL1=(sensorValue)");
  47. result = mysql_use_result(conn);
  48.  
  49. mysql_close (conn);
  50. exit (0);
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement