Author Topic: Arduino Code help  (Read 1079 times)

webber

  • New Member
  • *
  • Posts: 2
    • View Profile
Arduino Code help
« on: March 19, 2015, 01:46:58 PM »
Hello everyone,

I'm new in this area and my project is Sun Tracker. Thanks to Gabriel for your sharing! Really get help :)

I have some questions about the code, could anyone help me ?

I' not sure about the PIN assignment.

Code: [Select]
  //PIN ASSIGNMENT
  ///////////////////////////////////////////////////////////
    //Limit Switch Pin Assignment
    const int limitPin = 13;
   
    //SHIFT REGISTER PIN ASSIGNMENT
     //Pin connected to ST_CP of 74HC595
    int latchPin = 10;
    //Pin connected to SH_CP of 74HC595
    int clockPin = 12;
    ////Pin connected to DS of 74HC595
    int dataPin = 11;
   //END SHIFT REGISTER PIN ASSIGNMENT
   
   //PIN ASSIGNMENT FOR THE SWITCHES THAT CHANGE THE HELIOSTATS TARGET
    int switchPin1 = 14;   
    int switchPin2 = 15;   
    int switchPin3 = 16;

I just wondering" PIN ASSIGNMENT FOR THE SWITCHES THAT CHANGE THE HELIOSTATS TARGET " are pins of Arduino ? Because the Arduino UNO's PWM only lasts till 13.

Many Thanks!

Webber


Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Arduino Code help
« Reply #1 on: March 20, 2015, 07:10:14 PM »
Hi Webber and welcome to the forums!

The pins are indeed referring to the pins on the Arduino. Where did you find this code by the way? Did you find it through a web search? It's actually an old version of the program. The newest one is here. http://www.cerebralmeltdown.com/arduino-sun-tracking-heliostat-program-download-page/ I need to update the page with the old code and tell people where the new code is.

Since this is older code, it was written using an older version of the Arduino IDE which used pin assignments above 13 to refer to the analog pins A0, A1, etc. Now I believe that you can just put "A0" and similar to assign the analog pins.

Hope that helps,
Gabriel



webber

  • New Member
  • *
  • Posts: 2
    • View Profile
Re: Arduino Code help
« Reply #2 on: March 21, 2015, 08:41:01 AM »
 ;D Thank you Gabriel!

I found your code from the web search. It's really cool~

My project uses a GPS to provide the latitude and altitude, last week I test the program but it did't work. I know it might be the torque of my stepper motors so I decide to buy a Motor shield to drive them.  Hope it works  :P  BTW, do you have any good method to test if the problem is caused by the code? As I can only use compile to see if the code can be verified or not. Not sure about if it is correct :P

In my opinion, the limit switch is used to protect the tracker when it moves to the  limited degree and then the tracker will reset and go back to the initial position that we set before in Arduino. Can we set both azimuth and altitude pins to same pin in Arduino? I wonder what kind of Wind Protection Switch you use? I guess it is works as button?

Many thanks!  :)

Webber


Gabriel

  • Administrator
  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Arduino Code help
« Reply #3 on: March 23, 2015, 11:43:44 AM »
Hi Webber,

You might try testing just certain parts of your program to make sure that you have the electronics working. I don't know which shield you have, but it probably has example code for it which you can use to test and see if you have the wiring correct. From there you can then try and get it to work with the Sun Harvester Program.

Which code and which shield are you using? Knowing might help me understand better. Also, are you using the latest version of the program? I'm assuming that you are doing the electronics yourself?

The limit switch isn't really meant to protect anything. In this case the limit switch is used as a homing switch, and if it is triggered anytime after the machine resets, it will not stop the machine. Both the altitude and azimuth pins should be set as the same by default although they can be separate if needed.

I'm not sure I understand the question but the switch is just a basic switch, so I'm sure you can find one easily. The switch is technically wired the same as a button if that helps. Is that what you are asking?