Go Down

Topic: tengo problemas con mi primer codigo  (Read 654 times) previous topic - next topic

dv150n

Aug 11, 2020, 05:22 pm Last Edit: Aug 11, 2020, 06:20 pm by dv150n
estoy haciendo mi primer proyecto pero me aparecen barios errores que no entiendo y no se resolver en mi codigo alguien me puede ayudar con esto porfavor... tengo arduino uno

#include "UnoJoy.h"

void setup(){
  setupPins();
  setupUnoJoy();
}

void loop(){
  // Always be getting fresh data
  dataForController_t controllerData = getControllerData();
  setControllerData(controllerData);
}

void setupPins(void){
  // Set all the digital pins as inputs
  // with the pull-up enabled, except for the
  // two serial line pins
  for (int i = 2; i <= 12; i++){
    pinMode(i, INPUT);
    digitalWrite(i, HIGH);
  }
  pinMode(A4, INPUT);
  digitalWrite(A4, HIGH);
  pinMode(A5, INPUT);
  digitalWrite(A5, HIGH);
  pinMode(13, INPUT);
  digitalWrite(13, HIGH);
}

dataForController_t getControllerData(void){
 
  // Set up a place for our controller data
  //  Use the getBlankDataForController() function, since
  //  just declaring a fresh dataForController_t tends
  //  to get you one filled with junk from other, random
  //  values that were in those memory locations before
  dataForController_t controllerData = getBlankDataForController();
  // Since our buttons are all held high and
  //  pulled low when pressed, we use the "!"
  //  operator to invert the readings from the pins
  controllerData.l3On = !digitalRead(2);
  controllerData.r3On = !digitalRead(3);
  controllerData.triangleOn = !digitalRead(4);
  controllerData.l1On = !digitalRead(5);
  controllerData.squareOn = !digitalRead(6);
  controllerData.crossOn = !digitalRead(7);
  controllerData.dpadUpOn = !digitalRead(8);
  controllerData.dpadDownOn = !digitalRead(9);
  controllerData.dpadLeftOn = !digitalRead(10);
  controllerData.dpadRightOn = !digitalRead(11);
  controllerData.l2On = !digitalRead(12);
  controllerData.r2On = !digitalRead(13);
  controllerData.selectOn = !digitalRead(A4);
  controllerData.startOn = !digitalRead(A5);
 
  // Set the analog sticks
  //  Since analogRead(pin) returns a 10 bit value,
  //  we need to perform a bit shift operation to
  //  lose the 2 least significant bits and get an
  //  8 bit number that we can use 
  controllerData.leftStickX = analogRead(A0) >> 2;
  controllerData.leftStickY = analogRead(A1) >> 2;
  controllerData.rightStickX = analogRead(A2) >> 2;
  controllerData.rightStickY = analogRead(A3) >> 2;
  // And return the data!
  return controllerData;



groundFungus

#1
Aug 11, 2020, 05:50 pm Last Edit: Aug 11, 2020, 05:52 pm by groundFungus
There is a Spanish section..  You may get help faster there.

Read the how to use this forum-please read sticky to see how to properly post code.  Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.

Since you do not say which Arduino board that you have, we cannot try to compile the code to see the error(s).  Please include the entire error message.  It is easy to do.  There is a button (lower right of the IDE window) called "copy error message".  Copy the error and paste into a post in code tags.  Paraphrasing the error message leaves out important information.
You will save everyone's time if you read and follow the forum guidelines.  :)          
https://forum.arduino.cc/index.php/topic,148850.0.html
and
https://forum.arduino.cc/index.php?topic=97455.0

dv150n

Arduino:1.8.13 (Mac OS X), Tarjeta:"Arduino Uno"











sketch_aug11c:1:10: fatal error: UnoJoy.h: No such file or directory
 #include "UnoJoy.h"
          ^~~~~~~~~~
compilation terminated.
exit status 1
UnoJoy.h: No such file or directory


Este informe podría contener más información con
"Mostrar salida detallada durante la compilación"
opción habilitada en Archivo -> Preferencias.

groundFungus

The UnoJoy library is likely not installed properly.  It does not seem to be available via the library manager (the best way to install libraries).  You may have to install it manually.  Here is how.

You will save everyone's time if you read and follow the forum guidelines.  :)          
https://forum.arduino.cc/index.php/topic,148850.0.html
and
https://forum.arduino.cc/index.php?topic=97455.0

Chblasco

No has metido el código entre las llaves y no tengo ni idea de hasta donde va el código. por favor vuelve a postear y metes el código entre las llaves </>

Go Up