<p> Names: Period: Date: E-Textiles 1A Assignment 7B –- Sensor as Analog Input - Storyboard</p><p>Objectives: In this activity you will: ● Use a switch as input ● Program their own computational circuit using conditionals ● Write functions to organize and reuse code.</p><p>To turn in your completed answer document: 1. Named your document #-ECS-Asign8B–Storyboard-Last,First where # is your period. 2. Upload your file to Mr. Gonzalez Textiles’ DropItTo.me (https://dropitto.me/MrGonzalezTextiles ) 3. Use the password etextiles</p><p>Sensor as Analog Input – Storyboard Let’s get 0 to 5 lights to light up depending on the brightness.</p><p>NAMING SECTION: 1. Based on the variables declared in this section (see below), </p><p> int lightSensor = A5; int brightness = 0;</p><p> a. Which component on the Circuit Playground do you think is the light sensor?</p><p>2. Which variable above do you think we will use to hold the value from the light sensor?</p><p>SETUP SECTION: 3. Type in the line below that sets the variable “lightSensor” to INPUT</p><p> void setup(){ CircuitPlayground.begin(); pinMode(lightSensor, INPUT); Serial.begin(9600); }</p><p>4. Download and Open Light_Sensor_Starter.ino from the website. Experiment with the light sensor. </p><p> a. What’s the biggest number you can get? </p><p> b. What’s the smallest number you can get?</p><p>Fill in the blanks below to define ranges of numbers for each light pattern:</p><p> brightness is greater than or equal to 10 lights turn on</p><p> brightness is greater than or equal to and less than 8 lights turn on</p><p> brightness is greater than or equal to and less than 6 lights turn on</p><p> brightness is greater than or equal to and less than 4 lights turn on</p><p> brightness is greater than or equal to and less than 2 light turns on</p><p> brightness is less than or equal to 0 lights turn on BUILDING BLOCKS SECTION: In this section there are already functions defined for you: Function: Behavior: light0(); 0 lights on light2(); 2 lights on light4(); 4 lights on light6(); 6 lights on light8(); 8 lights on light10(); 10 lights on</p><p>ACTIVITY SECTION: 5. Complete the loop() function to call the functions from the BUILDING BLOCKS SECTION above for the conditions you specified in #4. Comparison Operators x == y (x is equal to y) x != y (x is not equal to y) x < y (x is less than y) x > y (x is greater than y) x <= y (x is less than or equal to y) x >= y (x is greater than or equal to y)</p><p> void loop() { // read the value from the sensor:</p><p> brightness = analogRead(lightSensor); Serial.println(brightness); delay(100);</p><p>//your code goes here: There are going to be 6 six conditionals. (six if’s) Example: if(brightness >= 123) { pattern }</p><p>}</p><p>6. Copy your code into your Arduino program, test, and debug.</p><p>7. In your own words, describe how your program chooses which light pattern function to call in the loop() function: </p>
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages5 Page
-
File Size-