Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * using PHPSerial (https://github.com/Xowap/PHP-Serial) on Beaglbone Black to send ON/OFF to Arduino's LED
- * and read LM35 sensor temperature. See Arduino code here: http://pastebin.com/J6fCNguP
- * almost all code is by: http://paolosarteschi.altervista.org/wp/?p=375
- * to connect Arduino & Beaglebone Black use:
- * www.instructables.com/id/How-to-make-a-BeagleBone-and-an-Arduino-communicat/?ALLSTEPS
- *
- */
- int tempPin = 0;// pin cui è collegato il sensore
- int temp;
- int LED = 13;
- int statoled;
- char oldval='a',val = '0';
- void setup() {
- pinMode(LED,OUTPUT);
- Serial.begin(9600);
- }
- void loop () {
- val = Serial.read();
- if(val!=oldval)
- oldval=val;
- if(oldval=='s'){
- digitalWrite(LED,LOW);
- Serial.print(0);
- }
- else if (oldval=='a'){
- digitalWrite(LED,HIGH);
- Serial.print(1);
- }
- else if (oldval=='r'){
- statoled = digitalRead(LED);
- if (statoled==0){
- Serial.print(0);
- }
- else {
- Serial.print(1);
- }
- }
- temp = ( 4.4 * analogRead(tempPin) * 100.0) / 1024.0;
- Serial.print(temp);
- delay(200);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement