Go Down

Topic: My modifications to Starter Kit. (Read 1 time) previous topic - next topic

alvaromat

Mar 28, 2015, 01:21 pm Last Edit: Mar 28, 2015, 01:23 pm by alvaromat Reason: Adding links
Let me introduce myself: I'm a computer engineering student from Spain and I have just acquired an Arduino Starter Kit to learn about micro controllers and electronics. I have noticed that the projects included in the book are very basic and don't teach a lot of programming neither electronics, so I've decided to tune the code of the projects and to share it (I don't know a lot about electronics, for that reason I will now only improve the code).
I know that my improvements are very basic and most users will probably find them useless, but if they help only one person I will be satisfied.
For all the modifications I assume that you have successful built the project as it is in the book.

Also I hope that this series of "tutorials" helps me learning English and expressing myself in this language. If you find that I use a colloquial expression or I just express myself bad send me a PM with your corrections, I will be very grateful.

Now it's time to begin.


Spaceship Interface (Only code modifications)
After modification:

Quote
Now yellow and red leds flicker like if, after firing a rocket, it chases the objective by a random time, and then all the leds are on telling us that the objective has been destroyed.
Video of the result: youtube
Link to the code: code in Github
The explanations are included in the code as comments
What can you learn?
  • Using preprocessor constants. Using this constants is the same as using the Find and replace tool of a text editor. They help us making our code more readable.
  • Using randomSeed(...) and random(min, max); to generate random numbers.
  • Using a for loop to repeat some sentences without writing them several times
  • Using your own method/function/procedure (The "shoot()" function)

Any doubt? Feel free to ask!




Go Up