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
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); |
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
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); | |
} |
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() {//這裡面要放最一開始執行的程式碼 | |
pinMode(LED_BUILTIN, OUTPUT); | |
} | |
void loop() {//此處程式碼會不斷地執行 | |
digitalWrite(LED_BUILTIN, HIGH); //把一個燈泡點亮(HIGH就是亮) | |
delay(1000); //讓它亮1秒(1000毫秒=1秒) | |
digitalWrite(LED_BUILTIN, LOW); //燈泡暗了(LOW就是暗) |
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
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 |
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
//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)) | |
} |
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
@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() |
OlderNewer