Skip to content

Instantly share code, notes, and snippets.

View ysam12345's full-sized avatar

yochien ysam12345

  • Taipei, Taiwan
View GitHub Profile
const int PIRSensor=2; //紅外線接腳
const int ledPin=13; //LED接腳
int tmp;
int sensorValue=0;
int buzzerPin=9; //蜂鳴器接腳
void setup(){ //設定輸入輸出
pinMode(PIRSensor, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
int trigPin = 12;
int echoPin = 11;
long duration, cm, inches;
void setup(){
Serial.begin(9600);
pinMode(trigPin, OUTPUT); //Define input and output
pinMode(echoPin, INPUT);
}
void setup() {//這裡面要放最一開始執行的程式碼
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {//此處程式碼會不斷地執行
digitalWrite(LED_BUILTIN, HIGH); //把一個燈泡點亮(HIGH就是亮)
delay(1000); //讓它亮1秒(1000毫秒=1秒)
digitalWrite(LED_BUILTIN, LOW); //燈泡暗了(LOW就是暗)
void setup() {
pinMode(A0, INPUT);
pinMode(13, OUTPUT);
}
void loop() {
int switchStatus;
switchStatus=digitalRead(A0);
if(switchStatus==HIGH)
{
pinMode(設定腳位, 設定模式);
pinMode(A0, INPUT);//腳位是A0,模式是接收訊號
pinMode(13, OUTPUT);//腳位是13,模式是送出訊號
if(2>1){//如果括弧合理
digitalWrite(13, HIGH);//該做什麼
}
void setup() {
pinMode(A0, INPUT);
pinMode(13, OUTPUT);
}
void loop() {
int switchStatus;
switchStatus=digitalRead(A0);
if(switchStatus==LOW)
{
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
//Push Notification Authorization
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in
}
UIApplication.shared.registerForRemoteNotifications()
// 讓 App 在前景狀態下收到通知
UNUserNotificationCenter.current().delegate = self
//get notification device token
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let deviceTokenString = deviceToken.reduce("") {
return $0 + String(format: "%02x", $1)
}
print(deviceTokenString)
//save device token
DeviceToken.save(deviceToken: DeviceToken(token: deviceTokenString))
}
@IBAction func btnLoginWithFacebookClicked(_ sender: Any) {
let fbLoginManager:FBSDKLoginManager = FBSDKLoginManager()
fbLoginManager.logIn(withReadPermissions: ["email"], from: self) {(result, error) in
if (error == nil){
let fbLoginResult:FBSDKLoginManagerLoginResult = result!
if fbLoginResult.grantedPermissions != nil {
if(fbLoginResult.grantedPermissions.contains("email")) {
self.getFBUserData()
self.turnToIndexSreen()
//fbLoginManager.logOut()