code for solar tracking system, error

Hi I need help for with my code, not working

Code_Code.txt (5.42 KB)

Start naming your constants, or you're never going to get it working - it's virtually illegible.

Is there some reason you are using direct port manipulation? Is speed really that critical when turning motors off and on?

The code you posted IS working. That is doesn’t do what you expect says more about your expectations than about the code.

What it ACTUALLY does is a mystery. What you want it to do is a mystery. I don’t care that much for mysteries. A good detective story, on the other hand…

IT GIVES MY ERROR WHEN TRY TO GET HEX FILE

tiay72: Hi I need help for with my code, not working

That code is a total crap.

It looks like 4 light sensors shall detect the brightest spot by "finding" it with rotating the motors.

But what type of light sensor may work just with four digital inputs to tell "all 4 sensors have Equal Light"?

I don't know what might be used for the sensors. Do you?

Schematic?

The code will guaranteed not work under these circumstances: - by night (perhaps a "moon finder" at night) - by day when dull sky (perhaps just a "motor mover" when dull sky)

There are even no "end stop" sensors. So perhaps the motors might come to a condition when they move in one direction until the power chord tears off.

This code cannot be used for anything usefull, except perhaps for demonstration purposes under laboratory controlled conditions with a human watching out, that the system doesn't run over the end stops.

You surely don't want that piece of crap code.

Please describe what you want!

HERE ARE THE ERRORS

THE ERROR.txt (1.39 KB)

Are you trying to compile the code as it appears in the attachment of your first post with all the comments broken across lines? If you are, the error messages should be really obvious.

Also, please don't SHOUT

int main(){

That is not an Arduino sketch. You should try the AVRfreaks forum (http://www.avrfreaks.net) for general AVR programming questions

johnwasser:

int main(){

That is not an Arduino sketch.

Why is some code no Arduino sketch if it has a main() function?

The Arduino IDE will easily compile programs with a “main()” function and no setup()/loop() in the .ino file.

Compiled from the Arduino IDE.

Proof of concept for Arduino UNO:

/*
 blink sketch for Arduino UNO
 this program will blink the pin-13 LED on ATMEGA328 bases Arduino boards
 no setup(), no loop(), just a main() function
 */

#include <util/delay.h>>

#define LED PB5   // PB5 is the pin-13 LED on an Arduino UNO board

int main(void) {
    DDRB = _BV(5);
    
    for(;;) {
        PORTB = _BV(5);
        _delay_ms(500);
        PORTB = 0;
        _delay_ms(500);
    }
    return 0;
}

You can write programs with main() and direct port programming as usual for AVR Atmegas.

If you initialize the Arduino core library within the main() function, you even can use many of the special Arduino “comfort” functions.

i want to you arduino uno, and need help with the code???

tiay72: i want to you arduino uno, and need help with the code???

Where is the original and not corrupted code?

From your questions I can see that the code has not been written by yourself.

And from the code I can see, that - the code is not complete (comment /* begins, but is never ending) - the code has corrupted formatting (comments broken to two lines)

Most likely you did a "copy-and-paste" from some original code, but you made a mistake so something went wrong and the line formatting is broken.

Perhaps it would be possible to restore the code with some effort, but if the wrong formatting is caused by an error with doing copy-and-paste, it would be much easier to take the code from the original source file.

Copying the code without making copy-and-paste errors.

Don't you have the original (not corrupted) file with the source code?