Please Help!

I am trying to program my multi program for my robot, i it is basically a loop that reads that switch and if you press the switch it adds 1 to a variable that will determine what program it will run.

I made a simple program here

I don’t think i am adding variables correctly, how do i add 1 to count?

The variable count is an integer and the program is suppose to add 1 to it.

This is how i have it (Count + 1); It does not work this way.

It is suppose to print count if the switch is turned on.

Any help would be greatly appreciated.

I think you want either “Count = (Count + 1);” or “Count += 1;”.

  • Dean

Ok here is what i need to know… i forgot to post it clearly

How do you add a variable and a number in user code and then take that value and store it in the variable.

Example

Count = 5

(Count + 13)

Now Count = 18

Change Count + 1 to
“Count++”

You can use the assignment block for this or you can input it yourself.

Technic-R-C

code:

#include<stdio.h>

main()
{
      int count = 5;
      int x;
      
      x = count + 13;
      printf("%d", x);
      
      getchar();
}

Enjoy

Technic-R-C

Its still not working, i just need to trouble shoot it some more so hang on.

I still haven’t tried the other method.

You forgot to put a “For/If loop” in that keeps track of how many times the bumper switch has been hit.

Technic-R-C

Yep thanks, i got it to work.

I gotta do some other work now so i made a quick program in a while loop.

Count = 0

Count = Count + 5;

Print Count to screen

and it keep going like that counting up and it doesn’t stop.

Here is a code that will execute only when the bumper is pushed. After 3 pushes, the code will end.

#include<stdio.h>

main()
{
      int x;
      
      while(1)
      {
              If (x <= 3)                      //code will execute until the bumper
              {                               //has been hit 3 times
                    Get bumper input.....
                    Wait 100;                 //get bumper input more often
                    
                    If ( bumper = 1);          //pressed switch
                    {
                         tell motors what to do...
                         x++;
                    }
              }
      }
}

Is this what you are looking for?

Technic-R-C

Jesus…
How long does it take to learn how to program?

The inventors guide will get you off to a good start.

In less than 1 day you should be able to program the robot to drive in a straight line, turn, and maybe some basic sensors like the bumper sensor.

And when i say 1 day i mean like 3 hours.

In 1 week you should have a basic and comfortable understanding of easy c programming.

Thats how it was for me!

You can ask questions here about programming if you don’t understand it, i know i did and know i am very proficient at programming in easy c.

Some sensor can be tricky to get working correctly and you can usually get help fast on the forum.

With determination and vigilience you will be comftarable programming in a couple of weeks, maybe days. The Easy C instruction manual helped a lot and so did this great website
http://gd.tuwien.ac.at/languages/c/programming-bbrown/

Technic-R-C

Lets see… I started in JAN-1982, so I guess that makes it 26 years, 1 month now… I did not learn ‘C’ until 1988, so that is only 20 years… And I am still learning…

There is an old Programmers Adage, “The Best Code I wrote 10 Minutes ago, the Worst Code I wrote 6 Months ago”. And the same thing is true everyday…

Technic-R-C

Excellent!!! I’ve added it to my list of Technical ‘C’ resources…

Exactly, this website was a great resource for learning C programming.

Technic-R-C