User Tools

Site Tools


workshops:arduino_for_the_curious:stage_1

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
workshops:arduino_for_the_curious:stage_1 [2017-04-09 21:49] Simonworkshops:arduino_for_the_curious:stage_1 [2017-04-09 21:52] (current) Simon
Line 60: Line 60:
 We now write our first program to make it blink. Here's the program code: We now write our first program to make it blink. Here's the program code:
  
 +<code>
 // Any text after two forward slashes is ignored by computers // Any text after two forward slashes is ignored by computers
 // These are called comments and are used to put notes for people inside code.  // These are called comments and are used to put notes for people inside code. 
Line 73: Line 73:
 void loop() { void loop() {
   digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)   digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
-  delay(1000);               // wait for 1000milli seconds (1 second)+  delay(1000);               // wait for 1000 milliseconds (1 second)
   digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW   digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
   delay(1000);               // wait for a second   delay(1000);               // wait for a second
 } }
 +</code>
  
 Copy this code into your Arduino software and upload it.  Copy this code into your Arduino software and upload it. 
Line 87: Line 87:
 Here's your first challenge! Try to complete both tasks. This will help you understand the code. Here's your first challenge! Try to complete both tasks. This will help you understand the code.
  
-| {{workshops:challenge_yourself.jpg?200x0}}| **Easier****(1)** The LED should be flashing once per 2 seconds. Can you make it flash 5 times per second?**(2)** Can you make the LED flash once for 1 second, then once for 0.2 seconds, then again for 1 second and so on in a dot-dash-dot-dash way? |+| {{workshops:challenge_yourself.jpg?200x0}}| **Easier** \\ **(1)** The LED should be flashing once per 2 seconds. Can you make it flash 5 times per second? \\ **(2)** Can you make the LED flash once for 1 second, then once for 0.2 seconds, then again for 1 second and so on in a dot-dash-dot-dash way? |
  
  
Line 96: Line 96:
 You might already be thinking. How do I know what my program is doing if all the feedback I have is a blinking LED? Well there is a solution in the form of serial communication which allows your Arduino to send messages to a computer. These messages can then be shown on your screen by clicking the button at the top right of the Arduino software. You might already be thinking. How do I know what my program is doing if all the feedback I have is a blinking LED? Well there is a solution in the form of serial communication which allows your Arduino to send messages to a computer. These messages can then be shown on your screen by clicking the button at the top right of the Arduino software.
  
-Note: when handling textual information in the Arduino programming language you need to use double quote marks. In this programming language "digitalWrite" represents text (d followed by an i, followed by a g, and so on, spelling the word digitalWrite), whereas digitalWrite (without the double quotes) is a reference to a feature of the programming language which allows you to control the voltage on various pins. +Note: when handling textual information in the Arduino programming language you need to use double quote marks. In this programming language ''"digitalWrite"'' represents text (d followed by an i, followed by a g, and so on, spelling the word digitalWrite), whereas ''digitalWrite'' (without the double quotes) is a reference to a feature of the programming language which allows you to control the voltage on various pins.
- +
  
 +<code>
 void setup() {                 void setup() {                
   // initialize the digital pin 13 as an output, in has the LED connected   // initialize the digital pin 13 as an output, in has the LED connected
Line 108: Line 107:
   // Sends a line to the computer   // Sends a line to the computer
   Serial.println("Hello World!");   Serial.println("Hello World!");
- 
 } }
  
Line 115: Line 113:
   Serial.println("LED On");   Serial.println("LED On");
   digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)   digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
-  delay(1000);               // wait for 1000milli seconds (1 second)+  delay(1000);               // wait for 1000 milliseconds (1 second)
   Serial.println("LED Off");   Serial.println("LED Off");
   digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW   digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
   delay(1000);               // wait for a second   delay(1000);               // wait for a second
 } }
 +</code>
  
 Once you've uploaded the program, open the Serial monitor: Once you've uploaded the program, open the Serial monitor:
Line 130: Line 128:
 So that's the end of the 1st lesson. So that's the end of the 1st lesson.
  
-Once the rest of the group has got to this point there will be another short presentation on programming concepts before moving onto [[stage_2|Tutorial 2]]+Once the rest of the group has got to this point there will be another short presentation on programming concepts before moving onto [[stage_2|Tutorial 2]].
  
workshops/arduino_for_the_curious/stage_1.1491774541.txt.gz · Last modified: 2017-04-09 21:49 by Simon

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki