test code of led strip for stm32
Dependencies: mbed ros_lib_kinetic
main.cpp
00001 #include "mbed.h" 00002 //#include "Servo.h", not neccesary 00003 #include <ros.h> 00004 #include <std_msgs/Int16.h> 00005 #include <std_msgs/Bool.h> 00006 00007 00008 ros::NodeHandle nh;// create node handle(executalbe file/object) 00009 00010 DigitalOut my_led(LED1); //trouble shootong, test led blink 00011 00012 00013 RawSerial device(PA_15,PB_7); //begin communication on these pins on stm32,(connect to Rx1 and Tx1 (18,19) communication bus, on arduino mega 2560 00014 00015 //std_msgs::Int16 led_msg; 00016 00017 int light_state= 0; // creat varaible 00018 00019 void led_state_callback(const std_msgs::Int16& msg) 00020 { 00021 00022 //DigitalOut 00023 light_state = msg.data; // 00024 //device.putc(light_state); //value that gets sent to th ctream 00025 } 00026 00027 00028 ros::Subscriber<std_msgs::Int16> led_state_subscriber("light_state", led_state_callback); 00029 00030 int main() { 00031 nh.initNode(); // start node 00032 nh.subscribe(led_state_subscriber); 00033 my_led = 0; 00034 while(1){ 00035 device.putc(light_state); 00036 my_led = !my_led; 00037 nh.spinOnce();// calls all subscriber 00038 wait_ms(5); 00039 } 00040 }
Generated on Fri Nov 4 2022 08:24:56 by
1.7.2