Bài đăng

Hiển thị các bài đăng có nhãn launchpad

lauchpad cc3200 điều khiển thiết bị qua wifi - control devices with Lauchpad cc3200 over wifi, LAN

Hình ảnh
Ví dụ dưới đây cho phép chúng ta điều khiển thiết bị điện thông qua mạng wifi/LAN một cách đơn giản. #ifndef __CC3200R1M1RGC__ // Do not include SPI for CC3200 LaunchPad #include <SPI.h> #endif #include <WiFi.h> // your network name also called SSID char ssid[] = "tên wifi"; // your network password char password[] = "password wifi"; // your network key Index number (needed only for WEP) int keyIndex = 0; int aa = 0; WiFiServer server(80); const int buttonPin = PUSH2; const int buttonPin1 = PUSH1; int buttonState = 0; int buttonState1 = 0; void setup() {   Serial.begin(115200);      // initialize serial communication   pinMode(RED_LED, OUTPUT);      // set the LED pin mode   pinMode(10, OUTPUT); pinMode(buttonPin, INPUT_PULLUP); pinMode(buttonPin1, INPUT_PULLUP);   // attempt to connect to Wifi network:   Serial.print("Attempting to connect to Network named: ");   // print the network name (SSID);   Serial.println

Kết nối Raspberry và MSP430G2553 thông qua giao tiếp UART

Hình ảnh
Kết nối: Mình đang dùng Raspberry phiên bản B, 26 chân. TX : chân số 8. RX : chân số 10. GND : chân số 6. thiết lập UART trên Raspberry PI, các bạn hãy tham khảo ở đây nhé! MSP430G2553 (lauchpad). RX : chân số 3. TX : chân số 4. chúng ta tiến hành kết nối 2 board lại với nhau như sau : RX nối TX của board kia, và ngược lại (đừng quên nối chung GND 2 board lại với nhau nhé). code lauchpad: //int a=0; //char a; //doc 1 ky tu String a; void setup() {   Serial.begin(9600); } void loop() {   //a = Serial.read();   a = Serial.readStringUntil('\n');   if(a == "anh yeu em")   {      Serial.write("OK\n");   } } code python : import serial from serial import Serial from time import sleep ser = Serial("/dev/ttyAMA0", 9600, timeout=2) while True:         ser.write("anh yeu em")         data = ser.read(50)         print data ser.close() chúc các bạn thành công!