Hi please read, i need help and i am stressed out now!

Hey guys i am Nuka (not my actual name.) i really need some help, i dont know where i should be posting this as i am new to Arduino. I have somewhere between very little to very basic skills with this, i am trying to make a joystick and 8x8 dot matrix and the matrix is max7219 board, i have hooked everything up properly, but my code really sucks and i also looked around and tried researching as much as i could before posting here, this is my code:

#include <LedControl.h>

LedControl lc = LedControl(8, 10, 9, 1);


// Arduino pin #'s

const int SW_pin = 2;
const int X_pin = A0; // ud
const int Y_pin = A1; // lr
int delayTime1 = 500;
int delayTime2 = 150;

void setup() {

  lc.shutdown(0, false);
  lc.setIntensity(0, 8);
  lc.clearDisplay(0);

  pinMode(SW_pin, INPUT);
  digitalWrite(SW_pin, HIGH);
  Serial.begin(9600);

}

void loop() {
  analogRead(A0);
  analogRead(A1);
  
  char X_translate = map(Y_pin, 1021, 0, 0, 4);
  char Y_translate = map(X_pin, 1021, 0, 0, 4);
  
  Serial.print("Switch: ");
  Serial.print(digitalRead(SW_pin));
  Serial.print("\n");
  Serial.print("X-axis: ");
  Serial.print(analogRead(X_pin));
  Serial.print("\n");
  Serial.print("Y-axis: ");
  Serial.print(analogRead(Y_pin));
  Serial.print("\n\n");
  delay(delayTime1);

  lc.clearDisplay(0);
  lc.setLed(0, X_translate, Y_translate, true);
  delay(delayTime2);

}

As for now i am giving up on it, my knowledge of arduino code is small and the website really isnt helping me and i dont just want to be a script kiddy copying and pasting other peoples code i acutally want to learn to write it all myself but i am frusterated becuse i have no clue how to learn but i am trying. i have looked up the refreces on the website but even that is hard for me to understand. i am very sorry for bad spelling aswell!

int UD = 0;
int LR = 0; //Setting up controller//
#include "LedControl.h" // need the library
LedControl lc=LedControl(8,10,9,1); //10 is to CLOCK, 9 = CS, 8=DIN//
void setup() {
 Serial.begin(9600);
 lc.shutdown(0,false); // turn off power saving, enables display
 lc.setIntensity(0,8); // sets brightness (0~15 possible values)
 lc.clearDisplay(0); // clear screen
}
void loop() {
 UD = analogRead(A0);
 LR = analogRead(A1);
 char x_translate = map(LR, 1021, 0, 7, 0); //This maps the values//
 char y_translate = map(UD, 1021, 0, 0, 7);

 Serial.print("UD = ");
 Serial.print(UD, DEC);
 Serial.print(", LR = ");
 Serial.print(LR, DEC);
 Serial.print(", x = ");
 Serial.print(x_translate, DEC);
 Serial.print(", y = ");
 Serial.println(y_translate, DEC);
 // not in shutdown mode
 lc.clearDisplay(0);
 lc.setLed(0,x_translate,y_translate,true);
 delay(150); //adjust delay to get your joystick correct//
}

this second code works fine but i really dont like it left is right and right is left. i want to be able to use the code that i was working on. i was using this code to help me with mine.

Welcome to the forum

What does your program do ?
What should it do ?
Does it even compile ?

Please do us all a favour and start by looking at Read this before posting a programming question which is one of the sticky posts at the top of the forum page. Note the advice regarding posting code and edit your first post to add code tags

Your code has prints in it.

They could be useful.

A more detailed explanation of what your program does than "my code really sucks" would help us to help you.

Also a diagram or clear photo showing exactly how you have hooked it up would help. You'd be surprised how often "hooked everything up properly" turns out not to be quite right after all.

Steve

nuka88:
As for now i am giving up on it, my knowledge of arduino code is small and the website really isnt helping me and i dont just want to be a script kiddy copying and pasting other peoples code i acutally want to learn to write it all myself but i am frusterated becuse i have no clue how to learn but i am trying. i have looked up the refreces on the website but even that is hard for me to understand. i am very sorry for bad spelling aswell!

Spoell checkers exist you know? :slight_smile:

Copying and modifying other people's code is the best way to learn, so get on with it. Look at the examples and modify them with abandon*. You learn by experience.

  • The term is actually gay abandon, but I'm not sure that we are allowed to say that anymore. :slight_smile:

OK, now just a couple of “starter” points on posting and in particular, posting code:

You need to go and read the forum instructions so that you can go back and modify your original post (not re-post it) - using the “More → Modify” option below the right hand corner of your post - to mark up your code as such using the “</>” icon in the posting window. Just highlight each section of code (or output if you need to post that) from the IDE and click the icon.

In fact, the IDE itself has a “copy for forum” link to put these markings on a highlighted block for you so you then just paste it here in a posting window. But even before doing that, don’t forget to use the “Auto-Format” (Ctrl-T) option first to make it easy to read. If you do not post it as “code” it can as you now see, be garbled to some degree and is always more difficult to read due to the font.

It is inappropriate to attach it as a “.ino” file unless it is clearly too long to include in the post proper. People can usually see the mistakes directly and do not want to have to actually load it in their own IDE. And even that would also assume they are using a PC and have the IDE running on that PC.

Also tidy up your blank space. Do use blank lines, but only single blanks between complete functional blocks.

AJLElectronics:

  • The term is actually gay abandon, but I’m not sure that we are allowed to say that anymore.

Oh I don’t know about that … :grinning:

Just keep your distance. (1.5 or 2 m, depends on jurisdiction. :roll_eyes: )

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Does your code compile?
What model Arduino are you using?

Thanks... Tom.... :slight_smile:

First off WELCOME !!!! glad you are here.

We have to deal in the hard details and hard facts and EVERY word has meaning. That is the nature of programming.

you posted

, i am trying to make a joystick and 8x8 dot matrix and the matrix is max7219 board,

I think I speak for all us us, but it is MUCH easier to just buy a joystick.

moving on, please post a link to any parts you have. and tell us what version of ardino you are using
also, if you can take a few pictures of your wiring, don't worry, we all do horrible wiring to get things to work so you are in a group where we have 'been there and done that'

also, please tell us the big picture. what is the overall project ? what do you plan do with the joystick ?

PLEASE,

read How to Use this Forum. it is a sticky post on the top of every forum.

it talks about useful subject lines. and can guarantee that anyone wanting to know about avoidance cars and mops will not search for 'stressed out'

to fix, go to your first post, and on the bottom right is the other/modify, and put in a useful subject line like 'need help with joystick and LED matrix'

UKHeliBob:
Welcome to the forum

What does your program do ? i want to use a joystick to controll 1 dot on the matrix, but i want to turn it into a
game where arrows pop up on the matrix then you have to move the thumb stick in the direction of the arrow and then have a circle to represent pushing down on the thumb stick and after each successful movement it will speed up but if you miss the right movement then a sound will play on the buzzing to let you know you lost.
What should it do ? for now i just want to move a dot around.
Does it even compile ? yes.

Please do us all a favour and start by looking at Read this before posting a programming question which is one of the sticky posts at the top of the forum page. Note the advice regarding posting code and edit your first post to add code tags