Wataru Kunino
/
sample01_led
An XBee ZB Coordinator on a Nucleo Board controls LEDs on the other XBee ZB device.
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 /********************************************************************* 00002 サンプルアプリ1 リモート先のLEDをON/OFFする。 00003 00004 Sample Code 1 LED 00005 An XBee ZB Coordinator on a Nucleo Board controls LEDs on the other 00006 XBee ZB device. 00007 When you will use this anything other than Nucleo microcomputer board, 00008 please change the 4th line of xbee/xbee.cpp: 00009 RawSerial _xbee_serial(SERIAL_TX, SERIAL_RX); 00010 00011 本ソースリストおよびソフトウェアは、ライセンスフリーです。 00012 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 00013 00014 Copyright (c) 2010-2014 Wataru KUNINO 00015 http://www.geocities.jp/bokunimowakaru/ 00016 *********************************************************************/ 00017 /* 00018 port: port指定 IO名 ピン番号 USB評価ボード(XBIB-U-Dev) 00019 port=11 DIO11 XBee_pin 7 LED2 ※port11がLED2 00020 port=12 DIO12 XBee_pin 4 LED1 ※port12がLED1 00021 */ 00022 #include "xbee.h" 00023 DigitalOut myled(LED1); 00024 00025 int main(){ 00026 // お手持ちのXBee子機(リモート先)アドレスに変更して下さい ↓ 00027 // Please set MAC Address to access your remote XBee device. 00028 byte dev_gpio[] = {0x00,0x13,0xA2,0x00,0x40,0x30,0xC1,0x6F}; 00029 00030 myled = 1; // NUCLEOのLEDをHレベル(3.3V)へ 00031 xbee_init( 0 ); // XBee用COMポートの初期化 00032 xbee_atnj( 0xFF ); // デバイスの参加を受け入れる 00033 myled = 0; // NUCLEOのLEDをHレベル(3.3V)へ 00034 00035 while(1){ // 永久に受信する 00036 myled = 1; // NUCLEOのLEDをHレベル(3.3V)へ 00037 xbee_gpo(dev_gpio,11,1); // GPOポート11をHレベル(3.3V)へ 00038 xbee_gpo(dev_gpio,12,1); // GPOポート12をHレベル(3.3V)へ 00039 wait(1); 00040 myled = 0; // NUCLEOのLEDをHレベル(3.3V)へ 00041 xbee_gpo(dev_gpio,11,0); // GPOポート11をLレベル(0.0V)へ 00042 xbee_gpo(dev_gpio,12,0); // GPOポート12をLレベル(0.0V)へ 00043 wait(1); 00044 } 00045 }
Generated on Sun Jul 24 2022 22:03:55 by 1.7.2