[{"data":1,"prerenderedAt":249},["ShallowReactive",2],{"lesson-3-01-design-expo":3},{"id":4,"title":5,"body":6,"chapterName":236,"chapterNumber":175,"description":237,"extension":238,"includesCode":184,"lessonNumber":163,"meta":239,"navigation":184,"path":240,"seo":241,"starterCode":242,"stem":243,"tags":244,"__hash__":248},"lessons/lessons/3-01-design-expo.md","Blinky @ Design Expo",{"type":7,"value":8,"toc":228},"minimark",[9,14,18,22,25,28,34,38,50,91,95,98,144,224],[10,11,13],"h2",{"id":12},"introduction","Introduction",[15,16,17],"p",{},"In this lesson, we'll cover the basics of circuits and electricity, and how to design your very first circuit using the\ncomponents in your kit. The goal of this project is to create a simple circuit with an LED that blinks on and off at a\nregular interval.",[10,19,21],{"id":20},"wiring-the-circuit","Wiring the Circuit",[15,23,24],{},"We have included below a circuit diagram that you should mirror in this project. Remember that the LED is directional,\nmeaning it will only light up if you connect it the right way.",[15,26,27],{},"You will want to use pin 1 as your source of positive voltage, and connect it in one closed loop through the LED and\nresistor back to ground (GND). Be careful of the direction of the LED. The arrow on the LED symbol on the components in\nyour kit indicates the direction of current flow.",[29,30],"img",{"alt":31,"src":32,"width":33},"Example basic circuit with an LED and resistor in series","/images/lessons/01-basic-circuit.svg","80%",[10,35,37],{"id":36},"writing-the-code","Writing the Code",[15,39,40,41,45,46,49],{},"Two question marks have been left in the starter code to guide you through writing the code to control your Blinky\ncircuit. As a reminder, a description of digitalWrite is provided below. Remember that ",[42,43,44],"code",{},"HIGH"," turns the pin on, and\n",[42,47,48],{},"LOW"," turns it off.",[51,52,53,76],"table",{},[54,55,56],"thead",{},[57,58,59,66,71],"tr",{},[60,61,62],"th",{},[63,64,65],"strong",{},"Function",[60,67,68],{},[63,69,70],{},"Description",[60,72,73],{},[63,74,75],{},"Usage",[77,78,79],"tbody",{},[57,80,81,85,88],{},[82,83,84],"td",{},"digitalWrite",[82,86,87],{},"Instructs a pin to output a digital signal until changed.",[82,89,90],{},"digitalWrite(#, HIGH/LOW);",[10,92,94],{"id":93},"testing-your-circuit","Testing Your Circuit",[15,96,97],{},"Once you have your circuit wired and your code written, you can test it out by running your program. If everything is\nset up correctly, you should see your LED blink on and off at a regular interval. If it's not working, double-check your\nwiring and make sure your code is correct. If you need, you can read through the solution below.",[99,100,101,105,125,129],"hint-section",{},[10,102,104],{"id":103},"code-hints","Code Hints",[106,107,108,112,122],"ul",{},[109,110,111],"li",{},"In setup, your only goal should be to set your chosen pin's mode. Output mode lets you turn the pin on and off with\ncode, while input mode lets you wanted to read a value from that pin, such as from a sensor. Which do you think you\nneed for this project?",[109,113,114,115,118,119,121],{},"Remember that ",[42,116,117],{},"delay()"," takes milliseconds, where 1 second is equal to 1000 milliseconds. If you want your LED to stay\non for 1 second and then off for 1 second, how many milliseconds should you pass to ",[42,120,117],{},"?",[109,123,124],{},"digitalWrite(pin, HIGH/LOW) is the command that turns your specified pin on or off. Which do you think you need to\nturn the LED on? Which do you need to turn it off?",[10,126,128],{"id":127},"circuit-hints","Circuit Hints",[106,130,131,138,141],{},[109,132,133,134,137],{},"Remember that a circuit needs to a few things: it must be a ",[63,135,136],{},"closed loop"," that flows from a power source, eventually\nto ground. To get the LED to light up, it will need to be a part of that circuit.",[109,139,140],{},"You will need your circuit to flow from the positive voltage, in this case, one of the numbered GPIO pins, through the\nLED and resistor, and back to ground (GND).",[109,142,143],{},"Make sure your LED is connected in the right direction. The arrow on the LED symbol on the components in your kit\nindicates the direction of current flow. The arrow should point from higher voltage towards ground.",[145,146,147,150,220],"solution-section",{},[15,148,149],{},"Below is the code for the project, and a full diagram of the wiring.",[151,152,157],"pre",{"className":153,"code":154,"language":155,"meta":156,"style":156},"language-cpp shiki shiki-themes github-light github-dark","void setup() {\n  pinMode(1, OUTPUT);\n}\n\nvoid loop() {\n  digitalWrite(1, HIGH);\n  delay(1000);\n  digitalWrite(1, LOW);\n  delay(1000);\n}\n","cpp","",[42,158,159,167,173,179,186,192,198,204,210,215],{"__ignoreMap":156},[160,161,164],"span",{"class":162,"line":163},"line",1,[160,165,166],{},"void setup() {\n",[160,168,170],{"class":162,"line":169},2,[160,171,172],{},"  pinMode(1, OUTPUT);\n",[160,174,176],{"class":162,"line":175},3,[160,177,178],{},"}\n",[160,180,182],{"class":162,"line":181},4,[160,183,185],{"emptyLinePlaceholder":184},true,"\n",[160,187,189],{"class":162,"line":188},5,[160,190,191],{},"void loop() {\n",[160,193,195],{"class":162,"line":194},6,[160,196,197],{},"  digitalWrite(1, HIGH);\n",[160,199,201],{"class":162,"line":200},7,[160,202,203],{},"  delay(1000);\n",[160,205,207],{"class":162,"line":206},8,[160,208,209],{},"  digitalWrite(1, LOW);\n",[160,211,213],{"class":162,"line":212},9,[160,214,203],{},[160,216,218],{"class":162,"line":217},10,[160,219,178],{},[29,221],{"alt":222,"src":223},"Solution wiring to blinky circuit","/images/lessons/02-01-blinky-solution.svg",[225,226,227],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":156,"searchDepth":169,"depth":169,"links":229},[230,231,232,233,234,235],{"id":12,"depth":169,"text":13},{"id":20,"depth":169,"text":21},{"id":36,"depth":169,"text":37},{"id":93,"depth":169,"text":94},{"id":103,"depth":169,"text":104},{"id":127,"depth":169,"text":128},"Design Expo Demo","Blink an LED on and off using your controller and code. This is the classic first project for learning how to control circuits with code.","md",{},"/lessons/3-01-design-expo",{"title":5,"description":237},"3-01-design-expo.cpp","lessons/3-01-design-expo",[245,246,42,247],"beginner","circuits","led","wHGygwhEbUjbJm6CAhy-deBnZtn09ra23yiqZSdRyI0",1776314085589]