Last active
September 28, 2017 11:42
-
-
Save Servuc/089b416923b6796aa0251a9503b39edb to your computer and use it in GitHub Desktop.
Teaching :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define SENSOR_PIN A0 | |
void setup() { | |
pinMode( SENSOR_PIN, INPUT ); | |
Serial.begin(9600); | |
} | |
void loop() { | |
Serial.println( analogRead( SENSOR_PIN ) ); | |
delay(2500); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define LED_PIN 13 | |
void setup() { | |
pinMode( LED_PIN, OUTPUT ); | |
} | |
void loop() { | |
digitalWrite( LED_PIN, LOW ); | |
delay(500); | |
digitalWrite( LED_PIN, HIGH ); | |
delay(500); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define LED_PIN 9 //Just update that :) | |
void setup() { | |
// put your setup code here, to run once: | |
pinMode( LED_PIN, OUTPUT ); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
digitalWrite( LED_PIN, LOW ); | |
delay(500); | |
digitalWrite( LED_PIN, HIGH ); | |
delay(500); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define LED_PIN 9 | |
#define LED_INFO_PIN 13 | |
#define SWITCH_PIN 2 | |
volatile bool mIsClicked = false; | |
void setup() { | |
attachInterrupt(digitalPinToInterrupt( SWITCH_PIN ), click, FALLING ); | |
pinMode( LED_PIN, OUTPUT ); | |
pinMode( LED_INFO_PIN, OUTPUT ); | |
pinMode( SWITCH_PIN, INPUT ); | |
digitalWrite( LED_PIN, LOW ); | |
Serial.begin(9600); | |
} | |
void loop() { | |
delay( 250 ); | |
digitalWrite( LED_INFO_PIN, HIGH ); | |
delay( 50 ); | |
digitalWrite( LED_INFO_PIN, LOW ); | |
if( mIsClicked ) { | |
Serial.println("Click"); | |
digitalWrite( LED_PIN, HIGH ); | |
delay( 2500 ); | |
digitalWrite( LED_PIN, LOW ); | |
mIsClicked = false; | |
} | |
} | |
void click() { | |
mIsClicked = true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define LED_PIN 9 //pin with ~ (PWM) | |
void setup() { | |
pinMode( LED_PIN, OUTPUT ); | |
} | |
void loop() { | |
for(int i = 0; i < 256; i++) { | |
analogWrite( LED_PIN, i ); | |
delay(20); | |
} | |
analogWrite( LED_PIN, 0); | |
delay(500); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup(void) { | |
Serial.begin(9600); | |
} | |
void loop() { | |
Serial.println("valeur"); | |
delay(5000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SerialPortLib = require('serialport'); | |
var myPort = new SerialPort.SerialPort('/dev/.....', { | |
baudRate:9600, dataBits:8, | |
parity:'none', stopBits:1, flowControl:false, | |
parser:SerialPort.parsers.readline("\r\n") | |
}); | |
myPort.on('open', function() { | |
myPort.write('message', function(err) { | |
if (err) { return console.error(err.message); } | |
}); | |
}); | |
myPort.on("data", function(message) { /* some works */ ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yarn add serialport | |
# npm install serialport | |
node votreScript.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment