mirror of
				https://github.com/digistump/DigistumpArduino.git
				synced 2025-11-03 21:14:46 -08:00 
			
		
		
		
	Initial import of support files for all Digistump boards - Digispark, Pro, DigiX - including libraries, examples, tools, and other support files for the Arduino IDE
This commit is contained in:
		@@ -0,0 +1,31 @@
 | 
			
		||||
#include <DigiUSB.h>
 | 
			
		||||
 | 
			
		||||
void setup() {
 | 
			
		||||
  DigiUSB.begin();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void get_input() {
 | 
			
		||||
  int lastRead;
 | 
			
		||||
  // when there are no characters to read, or the character isn't a newline
 | 
			
		||||
  while (true) { // loop forever
 | 
			
		||||
    if (DigiUSB.available()) {
 | 
			
		||||
      // something to read
 | 
			
		||||
      lastRead = DigiUSB.read();
 | 
			
		||||
      DigiUSB.write(lastRead);
 | 
			
		||||
      
 | 
			
		||||
      if (lastRead == '\n') {
 | 
			
		||||
        break; // when we get a newline, break out of loop
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    // refresh the usb port for 10 milliseconds
 | 
			
		||||
    DigiUSB.delay(10);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void loop() {
 | 
			
		||||
  // print output
 | 
			
		||||
  DigiUSB.println("Waiting for input...");
 | 
			
		||||
  // get input
 | 
			
		||||
  get_input();
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user