Skip to content

Instantly share code, notes, and snippets.

/*
Requirement NODEJS
- facebook-chat-api
- microgear
*/
/* ### START CONFIG ### */
var facebookEmail = 'email';
var facebookPassword = 'pass';
//NETPIe
int led = 9; // ประกาศ pin สำหรับการใช้ PWM
int brightness = 0; // ตัวแปรปรับความสว่าง (0-255)
void setup() {
pinMode(led, OUTPUT); //กำหนดให้ pin led เป็นขาส่งสัญญาณออก
}
void loop() {
analogWrite(led, brightness); //คำสั่งให้ led แสดงผล
}
int pushButton = 2;
/*เป็นการประกาศตัวแปรชนิด int (เก็บจำนวนเต็ม) ชื่อว่า pushButton โดยมีค่าเท่ากับ 2 เพื่อเก็บค่านี้ไว้ใช้ต่อในส่วนต่อไปของโปรแกรม*/
void setup() {
Serial.begin(9600);
/*ฟังก์ชั่น Serial.begin(9600); เป็นการเรียกใช้งาน Serial Communication ผ่านการเชื่อมต่อ Serial Port (ในที่นี้ Arduino จะใช้การเชื่อมต่อผ่าน USB โดยมี USB to Serial ภายใน) ด้วยความเร็วที่เชื่อมต่อคือ 9600 หรือเรียกว่าบรอทเรต 9600*/
void setup() {
Serial.begin(9600);
/*ฟังก์ชั่น Serial.begin(9600); เป็นการเรียกใช้งาน Serial Communication ผ่านการเชื่อมต่อ Serial Port (ในที่นี้ Arduino จะใช้การเชื่อมต่อผ่าน USB โดยมี USB to Serial ภายใน) ด้วยความเร็วที่เชื่อมต่อคือ 9600 หรือเรียกว่าบรอทเรต 9600*/
}
void loop() {
int ledState = LOW;
/* กำหนดตัวแปร ledState สำหรับเก็บสถานะเริ่มต้นของ led */
unsigned long previousMillis = 0;
/* กำหนดตัวแปน previousMillis สำหรับเก็บข้อมูลเวลาก่อนหน้า */
long interval = 1000;
/* กำหนดตัวแปร interval เพื่อใช้ในการปรับเปลี่ยนเวลาในการเปลียน ledState */
void setup() {
@jackrobotics
jackrobotics / antoTime.ino
Created August 7, 2016 08:29
antoTime.ino
#include <AntoIO.h>
AntoIO anto("JackRoboticS", "p7erLWvOQsdRAwVylmdF8eR0OX1VMNSHfk1GRzCX", "TIME");
int day,month,year,hours,minutes,seconds;
bool bIsConnected = false;
void setup() {
// SSID and Password of your WiFi access point.
const char* ssid = "HONEYLab";
var fs = require('fs');
// function to create file from base64 encoded string
function base64_decode(base64str, file) {
// create buffer object from base64 encoded string, it is important to tell the constructor that the string is base64 encoded
var bitmap = new Buffer(base64str, 'base64');
// write buffer to file
fs.writeFileSync(file, bitmap);
}
private void lineNotify(string msg)
{
string token = "9IBnp37LVHj0a6W5HLq2dF7sqIjGyEVn2DQtpQq7wYv";
try
{
var request = (HttpWebRequest)WebRequest.Create("https://notify-api.line.me/api/notify");
var postData = string.Format("message={0}", msg);
var data = Encoding.UTF8.GetBytes(postData);
request.Method = "POST";
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
import requests
url = 'https://notify-api.line.me/api/notify'
token = '9IBnp37LVHj0a6W5HLq2dF7sqIjGyEVn2DQtpQq7wYv'
headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer '+token}
msg = 'ทดสอบภาษาไทย hello'