ARDUINO FÜR ANFÄNGER: Wie man ein Arduino-Board auswählt, kauft und programmiert, um Schritt für Schritt erstaunliche Projekte zu erstellen (Scots_gaelic Edition) by Hopper Mark
Author:Hopper, Mark [Hopper, Mark]
Language: gla
Format: epub
Published: 2020-06-20T16:00:00+00:00
Kapitel 8: Den Sketch für andere Resultate bearbeiten
Now that we’ve written our first sketch, we can edit it. Editing a functioning sketch is a great way to learn how to code. It works one way, so it should work another, right?
But any programmer will tell you that editing a code is tricky work. The thing works, and so changing it might make it not work. When you’re working with code that is only a few lines long, it can be easy to find where your mistake is. But what if your sketch is pages and pages of code instead of just a handful of lines?
This is why I advocate two things: saving your sketches with new names (so for our example, you can change Arduino_test_10152019 to Arduino_edit_10152019) and annotating your sketch using the comment syntax. The first part is to make sure you always have functioning sketches that you like. If you edit something without saving a new version, you might not be able to get back to the previous state. And the second part is just for your own peace of mind. Always think of your future self. You’ll thank yourself for it later .
Wie bearbeite ich einen Sketch?
After saving a new sketch under a new name, editing your sketch is as simple as changing the code contained in the sketch. For the Blink example, perhaps you want the LED to blink less often (maybe every ten seconds instead of every second?) or more often (maybe every half a second!). Both are completely valid things you could do, although the complexity varies wildly.
But that’s not all!
The simplest of sketches can be modified by adding new code instead of just modifying the numbers already there. Let’s say you want to have an LED where the flashing gets slower as the number of loops goes up. It can be done!
Editing your code is a great way to experiment with what a certain bit of code will do to your sketch. Perhaps you don’t quite understand how for statements work and want to experiment. Editing your sketch and changing only one or two things at a time will allow you to see exactly how the code works and what it does.
Einen Blink-Sketch bearbeiten (Teil 1 )
I think we’ll start with something simple: decreasing the time between blinks on your sketch. In general, this is the simplest change but one that requires you to understand exactly how the delay() function works.
Here is the new code with edits made. See if you can spot the difference.
/*
Arduino Blink version 2.0
We are going to be turning an LED (either on the board or an external LED) on and off at half-second intervals. This is based on the Arduino Tutorial Blink, but with a bit more explanation to it. If you want to see the original code, check out http://www.arduino.cc/en/Tutorial/Blink .
*/
void setup () {
// establishing LED_BUILTIN as output
pinMode (LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite (LED_BUILTIN, HIGH); // this sets the voltage level to HIGH, turning on the LED
delay(500); //
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Linux Device Driver Development Cookbook by Rodolfo Giometti(3957)
Embedded Programming with Modern C++ Cookbook by Igor Viarheichyk(3783)
Implementing Cellular IoT Solutions for Digital Transformation by Dennis McCain(3703)
Embedded Linux Development Using Yocto Project - Third Edition by Otavio Salvador & Daiane Angolini(3551)
TinyML Cookbook by Gian Marco Iodice(3470)
Simplifying 3D Printing with OpenSCAD by Colin Dow(2861)
TinyML Cookbook by Gian Marco Iodice & Ronan Naughton(2623)
Fusion 360 for Makers by Lydia Sloan Cline(2230)
Networking A Beginner's Guide by Bruce Hallberg(2228)
Hands-On Linux for Architects by Denis Salamanca(2073)
But How Do It Know? by J. Clark Scott(2039)
Computers For Seniors For Dummies by Nancy C. Muir(2023)
Raspberry Pi and MQTT Essentials by Dhairya Parikh(1980)
Arduino Project Handbook, Volume 2: 25 Simple Electronics Projects for Beginners by Geddes Mark(1963)
9781803246888-ENHANCING DEEP LEARNING WITH BAYESIAN INFERENCE by Unknown(1918)
Hack and HHVM by Owen Yamauchi(1904)
31 Days Before Your CompTIA A+ Exams (Shanette Luellen's Library) by Benjamin Patrick Conry(1878)
MicroPython Projects by Jacob Beningo(1768)
Hands-On Internet of Things with MQTT by Tim Pulver(1728)
