Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Teaching :)
#define SENSOR_PIN A0
void setup() {
pinMode( SENSOR_PIN, INPUT );
Serial.begin(9600);
}
void loop() {
Serial.println( analogRead( SENSOR_PIN ) );
delay(2500);
}
#define LED_PIN 13
void setup() {
pinMode( LED_PIN, OUTPUT );
}
void loop() {
digitalWrite( LED_PIN, LOW );
delay(500);
digitalWrite( LED_PIN, HIGH );
delay(500);
}
#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);
}
#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;
}
#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);
}
void setup(void) {
Serial.begin(9600);
}
void loop() {
Serial.println("valeur");
delay(5000);
}
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 */ );
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