- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.1k
 
Closed
Description
I wrote this code to test communication over usb with my pico but it doesn't work each time.
When it work, it only work a couples of times until stop working.
I doesn't understand why, can you help me?
Here is my code
#include "pico/stdlib.h"
#include  <iostream>
int main() {
	// init gpio
	gpio_init(PICO_DEFAULT_LED_PIN);
	gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
	// init usb
	stdio_usb_init();
	while (!stdio_usb_connected()) { // blink until usb is connected
		gpio_put(PICO_DEFAULT_LED_PIN, 1);
		sleep_ms(250);
		gpio_put(PICO_DEFAULT_LED_PIN, 0);
		sleep_ms(250);
	}
	std::cout<<"Send 1 to turn on, 0 to turn off, other number to exit"<<std::endl;
	int ledState = 0;
	while (ledState < 2 && ledState >= 0) {
		std::cin>> ledState;
		std::cout<<"ledState: "<<ledState<<std::endl;
		gpio_put(PICO_DEFAULT_LED_PIN, ledState);
	}
	std::cout<<"Good bye !"<<std::endl;
	return 0;
}I use screen command to send and receive data
I'm on arch linux and I use the last sdk version
Thanks