mirror of
				https://github.com/0xFEEDC0DE64/arduino-esp32.git
				synced 2025-11-04 08:01:38 +01:00 
			
		
		
		
	
		
			
	
	
		
			22 lines
		
	
	
		
			510 B
		
	
	
	
		
			Arduino
		
	
	
	
	
	
		
		
			
		
	
	
			22 lines
		
	
	
		
			510 B
		
	
	
	
		
			Arduino
		
	
	
	
	
	
| 
								 | 
							
								#include "USB.h"
							 | 
						||
| 
								 | 
							
								#include "USBHIDConsumerControl.h"
							 | 
						||
| 
								 | 
							
								USBHIDConsumerControl ConsumerControl;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								const int buttonPin = 0;
							 | 
						||
| 
								 | 
							
								int previousButtonState = HIGH;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void setup() {
							 | 
						||
| 
								 | 
							
								  pinMode(buttonPin, INPUT_PULLUP);
							 | 
						||
| 
								 | 
							
								  ConsumerControl.begin();
							 | 
						||
| 
								 | 
							
								  USB.begin();
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void loop() {
							 | 
						||
| 
								 | 
							
								  int buttonState = digitalRead(buttonPin);
							 | 
						||
| 
								 | 
							
								  if ((buttonState != previousButtonState) && (buttonState == LOW)) {
							 | 
						||
| 
								 | 
							
								    ConsumerControl.press(CONSUMER_CONTROL_VOLUME_INCREMENT);
							 | 
						||
| 
								 | 
							
								    ConsumerControl.release();
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								  previousButtonState = buttonState;
							 | 
						||
| 
								 | 
							
								}
							 |