bonjour
Pour un projet de fac , je dois lier un esp32 (Heltec wifi kit) a un émulateur nes
le code fonctionne , il écrit les chiffres demander mais lorsque je veux créer les inputs dans émulateur , ce dernier ne reconnais pas la pression sur la touche.
voici mon code :
// Basic demo for accelerometer readings from Adafruit MPU6050
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
#include <WiiChuck.h>
#include <BleKeyboard.h>
#include "Adafruit_Sensor_Calibration.h"
#include "GY521.h"
GY521 sensor(0x68);
uint32_t counter = 0;
// select either EEPROM or SPI FLASH storage:
#ifdef ADAFRUIT_SENSOR_CALIBRATION_USE_EEPROM
Adafruit_Sensor_Calibration_EEPROM cal;
#else
Adafruit_Sensor_Calibration_SDFat cal;
#endif
/*
pin scl->c->22
pin sda->z->21
*/
BleKeyboard bleKeyboard;
Accessory nunchuck;
Adafruit_MPU6050 mpu;
void setup() {
Serial.begin(115200);
Wire.begin(21, 22, 100000); // sda, scl, clock speed
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU−6050)
Wire.endTransmission(1);
Serial.println("Setup complete");
bleKeyboard.begin();
nunchuck.begin();
mpu.begin();
if (nunchuck.type == Unknown) {
nunchuck.type = NUNCHUCK;
}
// set calibration values from calibration sketch.
sensor.axe = 0.574;
sensor.aye = -0.002;
sensor.aze = -1.043;
sensor.gxe = 10.702;
sensor.gye = -6.436;
sensor.gze = -0.676;
}
void loop() {
sensor.read();
float x = sensor.getAngleX();
float y = sensor.getAngleY();
float z = sensor.getAngleZ();
nunchuck.readData(); // Read inputs and update maps
Serial.println(x);
Serial.println(z);
// Serial.print("X: ");
// Serial.print(nunchuck.getAccelX());
// Serial.print(" \tY: "); Serial.print(nunchuck.getAccelY());
// Serial.print(" \tZ: "); Serial.println(nunchuck.getAccelZ());
// Serial.print("Joy: (");
// Serial.print(nunchuck.getJoyX());
// Serial.print(nunchuck.getJoyY());
Serial.print("Button: ");
if (nunchuck.getButtonZ()) Serial.print(" Z ");
if (nunchuck.getButtonC()) Serial.print(" C ");
Serial.println();
delay(100);
//touche du clavier en fonction des condition
if(nunchuck.getJoyY()< 70) {
bleKeyboard.press(KEY_NUM_0);
bleKeyboard.releaseAll();
Serial.print("waza1");}
delay(50);
if(nunchuck.getJoyX() > 180) {
bleKeyboard.press(KEY_NUM_1);
bleKeyboard.releaseAll();
Serial.print("waza2");}
delay(50);
if(nunchuck.getJoyY()>180) {
bleKeyboard.press(KEY_NUM_3);
bleKeyboard.releaseAll();
Serial.print("waza3");}
delay(50);
if(nunchuck.getJoyX() < 70) {
bleKeyboard.press(KEY_NUM_4);
bleKeyboard.releaseAll();
Serial.print("waza4");}
delay(50);
if(nunchuck.getButtonC()) {
bleKeyboard.press(KEY_NUM_5);
bleKeyboard.releaseAll();
Serial.print("waza5");delay(50);}
if(nunchuck.getButtonZ()) {
bleKeyboard.press(KEY_NUM_6);
bleKeyboard.releaseAll();
Serial.print("waza6");delay(50); }
if(z<-15) {
bleKeyboard.press(KEY_NUM_2);
bleKeyboard.releaseAll();
Serial.print("waza7");delay(50);}
if( x<0) {
bleKeyboard.press(KEY_NUM_7);
bleKeyboard.releaseAll();
Serial.print("waza8");}
delay(50);
if(x>90) {
bleKeyboard.press(KEY_NUM_8);
bleKeyboard.releaseAll();
Serial.print("waza9");}
delay(50);
if(z>-5) {
bleKeyboard.press(KEY_NUM_9);
bleKeyboard.releaseAll();
Serial.print("waza");
delay(50); }
delay(200);
}
Merci par avance pour votre aide