
<?php $hostname = "localhost"; $username = "_"; $password = ""; $database = "_"; $connect_DB = mysql_connect($hostname, $username, $password); //   if (!$connect_DB) { //    exit; //   } mysql_select_db($database); //  changeLED(); // ,    mysql_close($connect_DB); //    function changeLED() //   { $query = "SELECT `status` FROM leds WHERE `id` = '1'"; //      leds (id = 1 -  ) $result = mysql_query($query); while ($_row = mysql_fetch_array($result,MYSQL_NUM)) //     { //   $st = (int)$_row[0]; if ($st == 0) $st = 1; else $st = 0; } $query = "UPDATE leds SET `status` = '$st' WHERE `id` = '1'"; //     $result = mysql_query($query); } ?>  <?php $hostname = "localhost"; $username = "_"; $password = ""; $database = "_"; $connect_DB = mysql_connect($hostname, $username, $password); //   if (!$connect_DB) { //    exit; //   } mysql_select_db($database); //  changeText(); // ,  ,   LCD- mysql_close($connect_DB); //    function changeText() { $st= $_GET["msg"]; //GET- msg  ,    $query = "UPDATE texts SET `text` = '$st' WHERE `id` = '1'"; //     texts    id = 1 ( LCD-) $result = mysql_query($query); } ?>  import processing.serial.*; //    COM- import de.bezier.data.sql.*; //     MySQL Serial port; MySQL dbconnection; int prevLEDState = 0; //   String prevS = ""; // ,   LCD- void setup() { port = new Serial(this, "COM4", 9600); // COM- 4 (   ),   - 9600  port.bufferUntil('\n'); String user = "_"; String pass = ""; String database = "_"; dbconnection = new MySQL( this, "_.ru", database, user, pass ); //   dbconnection.connect(); } void draw() { //       dbconnection.query( "SELECT * FROM leds WHERE id = '1'" ); //    leds while (dbconnection.next()) //     { int n = dbconnection.getInt("status"); //    status if (n != prevLEDState) //       ""  ,     COM- { prevLEDState = n; port.write('1'); //       : 1 -  , 2 -  LCD- port.write(n); } } //    LCD-   dbconnection.query( "SELECT * FROM texts WHERE id = '1'" ); //    texts while (dbconnection.next())//     { String s = dbconnection.getString("text"); //    text if (s != prevS) { prevS = s; port.write('2'); port.write(s); } } delay(50); //   50 ,      } 

 public void changeLED() { try { URL url1 = new URL("http://_.ru/led.php"); HttpURLConnection urlConnection = (HttpURLConnection) url1.openConnection(); try { InputStream in = new BufferedInputStream(urlConnection.getInputStream()); } finally { urlConnection.disconnect(); } } catch (Exception e) { } }  public void submitMsg() { final EditText tt = (EditText) findViewById(R.id.editText1); try { URL url1 = new URL("http://_.ru/msg.php?msg="+tt.getText()); HttpURLConnection urlConnection = (HttpURLConnection) url1.openConnection(); try { InputStream in = new BufferedInputStream(urlConnection.getInputStream()); } finally { urlConnection.disconnect(); } } catch (Exception e) { } }  public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final Button btn1 = (Button) findViewById(R.id.button1); btn1.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) //    { changeLED(); } }); final Button btn2 = (Button) findViewById(R.id.button2); btn2.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) //    { submitMsg(); } }); }  <uses-permission android:name="android.permission.INTERNET"/> 

 #include <LiquidCrystal.h> //     LCD- boolean isExecuting = false; //, ,     -  //C ,    .   ""  loop    COM-   . //      .         (       ) //    (1  2 ).         (     ), //  . LiquidCrystal lcd(4,5,10,11,12,13); //  int ledPin = 8; //  ,      int prevLEDStatus = 0; //   (/) int newLEDStatus = 0; //   int cmd = 0; //   void setup() { Serial.begin(9600); // COM- (9600 -    ) pinMode(ledPin,OUTPUT); // 8-     lcd.begin(20,4); // LCD- (4   20 ) } void loop() { if (Serial.available() > 0) //  COM-  -  { if (isExecuting == false) //         { cmd = Serial.read() - '0'; //    isExecuting = true; //  ,     } if (cmd == 1) //  { newLEDStatus = (int) Serial.read(); //    if (newLEDStatus != prevLEDStatus) //       ,     { digitalWrite(ledPin,newLEDStatus); prevLEDStatus = newLEDStatus; } } else //  { if (isExecuting == false) //         { lcd.clear(); //  } else { lcd.print((char)Serial.read()); //    } } } else //  COM-     { delay(50); //   50  if (Serial.available() <= 0) //  -  isExecuting = false; //,      } } Source: https://habr.com/ru/post/137155/
All Articles