[{"data":1,"prerenderedAt":1823},["ShallowReactive",2],{"platform-picobricks":3},[4,366,648,912,1223,1550],{"id":5,"title":6,"body":7,"description":343,"draft":346,"duration":347,"extension":348,"image":349,"kit":350,"language":355,"level":356,"meta":357,"navigation":358,"path":359,"pdf":360,"platform":361,"seo":362,"stem":363,"youtube":364,"__hash__":365},"tutorials\u002Flearn\u002Fpicobricks\u002Fautomatic-lighting\u002Findex.md","Automatic Lighting",{"type":8,"value":9,"toc":342},"minimark",[10],[11,12,13,56,62,69,103,245,257,276],"tutorial-steps",{},[14,15,17,32],"step",{"title":16},"Overview",[18,19,20,21,26,27,31],"p",{},"In this project we'll build our very own automatic light, just like the ones that switch themselves on when it gets dark. We'll use the ",[22,23,25],"g",{"slug":24},"light-sensor","Light Sensor"," to measure how bright it is around us. When it gets too dark, the ",[22,28,30],{"slug":29},"rgb-led","RGB LED"," will switch on all by itself, and when it's bright again, it turns back off.",[33,34,37,43],"callout",{"color":35,"icon":36},"green","🎯",[18,38,39],{},[40,41,42],"strong",{},"What you'll learn",[44,45,46,50,53],"ul",{},[47,48,49],"li",{},"How a light sensor measures the light around it",[47,51,52],{},"How to use an if\u002Felse block to make a decision",[47,54,55],{},"How to switch an RGB LED on and off automatically",[14,57,59],{"title":58},"What you'll need",[60,61],"what-youll-need",{},[14,63,65],{"title":64},"Key words",[66,67],"key-words",{"terms":68},"light-sensor,rgb-led,forever-loop,if-statement,threshold",[14,70,72,96],{"title":71},"Set up your PicoBricks",[73,74,75,86,89],"ol",{},[47,76,77,78,85],{},"Open your favourite web browser. We recommend either Google Chrome or Microsoft Edge. Type ",[79,80,84],"a",{"href":81,"rel":82},"http:\u002F\u002Fide.picobricks.com",[83],"nofollow","ide.picobricks.com"," into the address bar.",[47,87,88],{},"Connect the PicoBricks board to your computer using the USB cable.",[47,90,91,92,95],{},"Connect the PicoBricks board to the Brick IDE by selecting the ",[40,93,94],{},"Connection"," button at the top of the code area.",[18,97,98],{},[99,100],"img",{"alt":101,"src":102},"The PicoBricks Brick IDE coding environment","\u002Flearn\u002Fpicobricks\u002Fautomatic-lighting\u002FCodingEnvironment.webp",[14,104,106,239],{"title":105},"Build the code",[73,107,108,120,134,144,159,172,189,202,220,229],{},[47,109,110,111,114,115,119],{},"Select ",[40,112,113],{},"Basic",". Drop a ",[116,117,118],"code",{},"PicoBricks"," block into the code area.",[47,121,110,122,125,126,130,131,133],{},[40,123,124],{},"Loops",". Snap a ",[22,127,129],{"slug":128},"forever-loop","forever"," block to the ",[116,132,118],{}," block.",[47,135,110,136,125,138,141,142,133],{},[40,137,113],{},[116,139,140],{},"Serial Print"," block inside the ",[116,143,129],{},[47,145,110,146,125,149,152,153,155,156,158],{},[40,147,148],{},"Bricks",[116,150,151],{},"Read Light Sensor"," block onto the ",[116,154,140],{}," block where it says ",[40,157,118],{},".",[47,160,110,161,164,165,130,169,133],{},[40,162,163],{},"Logic",". Snap an ",[22,166,168],{"slug":167},"if-statement","if else",[116,170,171],{},"Serial Print Read Light Sensor",[47,173,110,174,164,176,152,179,182,183,185,186,158],{},[40,175,163],{},[116,177,178],{},"=",[116,180,181],{},"if"," block, then change the ",[40,184,178],{}," to a ",[40,187,188],{},">",[47,190,110,191,193,194,196,197,199,200,158],{},[40,192,148],{},". Add a ",[116,195,151],{}," block into the first blank space of the ",[116,198,181],{}," block, before the ",[40,201,188],{},[47,203,110,204,125,207,210,211,213,214,216,217,158],{},[40,205,206],{},"Math",[116,208,209],{},"0"," block into the space after the ",[40,212,188],{},", then change ",[40,215,209],{}," to ",[40,218,219],{},"10,000",[47,221,110,222,125,224,141,227,133],{},[40,223,30],{},[116,225,226],{},"Set RGB Led Colour",[116,228,181],{},[47,230,110,231,125,233,141,236,133],{},[40,232,30],{},[116,234,235],{},"Clear RGB Led Colour",[116,237,238],{},"else",[18,240,241],{},[99,242],{"alt":243,"src":244},"The finished Automatic Lighting code","\u002Flearn\u002Fpicobricks\u002Fautomatic-lighting\u002FAutomaticLightingCode.webp",[14,246,248,251],{"title":247},"Run it and Watch",[18,249,250],{},"Now the code is finished, let's run it and check it works. Select the run button at the top of the code area. If it's daylight the RGB LED should be off. If it's night time, or if you cover the light sensor with your hand, the RGB LED will turn on.",[18,252,253],{},[99,254],{"alt":255,"src":256},"Automatic Lighting demo","\u002Flearn\u002Fpicobricks\u002Fautomatic-lighting\u002FAutomaticLightingDemo.gif",[14,258,260],{"title":259},"Try it yourself",[261,262,263],"try-it",{},[18,264,265,268,269,271,272,275],{},[40,266,267],{},"Challenge:"," Can you make your night light more colourful? Try changing the ",[40,270,226],{}," block to a different colour, so your light glows blue, green or purple when it gets dark. Feeling brave? Add a ",[40,273,274],{},"Buzzer"," block so it gives a gentle beep the moment the light comes on.",[14,277,279],{"title":278},"Stuck? Quick fixes",[280,281,282,295],"table",{},[283,284,285],"thead",{},[286,287,288,292],"tr",{},[289,290,291],"th",{},"Problem",[289,293,294],{},"Try this",[296,297,298,309,317,325],"tbody",{},[286,299,300,304],{},[301,302,303],"td",{},"The RGB LED won't turn on at all",[301,305,306,307,133],{},"Cover the light sensor fully with your hand to make it really dark. If it still won't light up, your room might not get dark enough to push the reading past the cut-off, so try lowering the 10,000 value in your ",[116,308,181],{},[286,310,311,314],{},[301,312,313],{},"The RGB LED is always on",[301,315,316],{},"Your everyday room light is already reading above the cut-off. Try raising the 10,000 value so the light only comes on when it's properly dark.",[286,318,319,322],{},[301,320,321],{},"Nothing happens when I press Run",[301,323,324],{},"Check the PicoBricks board is connected (the connection button at the top should show it's linked). Unplugging and replugging the USB cable often does the trick.",[286,326,327,330],{},[301,328,329],{},"I can't see the light readings",[301,331,332,333,335,336,338,339,341],{},"Make sure the ",[116,334,140],{}," block is inside the ",[116,337,129],{}," loop, with the ",[116,340,151],{}," block snapped into it.",{"title":343,"searchDepth":344,"depth":344,"links":345},"",2,[],false,"10 mins","md","\u002Flearn\u002Fpicobricks\u002Fautomatic-lighting\u002Fcover-automatic-lighting.png",[351,352,353,354],"PicoBricks Kit","PicoBricks Brick IDE","MicroUSB to USB cable","Laptop or tablet for coding",null,"Beginner",{},true,"\u002Flearn\u002Fpicobricks\u002Fautomatic-lighting","\u002Flearn\u002Fpicobricks\u002Fautomatic-lighting\u002Fautomatic-lighting.pdf","picobricks",{"title":6,"description":343},"learn\u002Fpicobricks\u002Fautomatic-lighting\u002Findex","https:\u002F\u002Fyoutu.be\u002FzBP0ivO4ypg","E7U8gAnK2V1b7nSpq3kemKJHqKKpPHLKP5j3mW7rD-E",{"id":367,"title":368,"body":369,"description":343,"draft":346,"duration":347,"extension":348,"image":639,"kit":640,"language":355,"level":356,"meta":641,"navigation":358,"path":642,"pdf":643,"platform":361,"seo":644,"stem":645,"youtube":646,"__hash__":647},"tutorials\u002Flearn\u002Fpicobricks\u002Fblinking-led\u002Findex.md","Blinking LED Project",{"type":8,"value":370,"toc":637},[371],[11,372,373,410,414,419,439,528,549,568],{},[14,374,375,385,396,399],{"title":16},[18,376,377,378,381,382,384],{},"In computer programming, when learning a new coding language we typically create a ",[40,379,380],{},"Hello World"," project, which prints ",[40,383,380],{}," to the screen.",[18,386,387,388,390,391,395],{},"When working with robotics and physical computing, our ",[40,389,380],{}," project becomes a blinking ",[22,392,394],{"slug":393},"led","LED"," (light-emitting diode).",[18,397,398],{},"Let's take a look at how we'd create this on the PicoBricks using the Brick IDE.",[33,400,401,405],{"color":35,"icon":36},[18,402,403],{},[40,404,42],{},[44,406,407],{},[47,408,409],{},"How to make an LED blink on and off",[14,411,412],{"title":58},[60,413],{},[14,415,416],{"title":64},[66,417],{":terms":418},"led, forever-loop",[14,420,421,434],{"title":71},[73,422,423,428,430],{},[47,424,77,425,85],{},[79,426,84],{"href":81,"rel":427},[83],[47,429,88],{},[47,431,91,432,95],{},[40,433,94],{},[18,435,436],{},[99,437],{"alt":101,"src":438},"\u002Flearn\u002Fpicobricks\u002Fblinking-led\u002FCodingEnvironment.webp",[14,440,441,519,525],{"title":105},[73,442,443,451,460,475,492,506],{},[47,444,110,445,447,448,450],{},[40,446,113],{},". Select a ",[116,449,118],{}," block and drop it in the code area.",[47,452,110,453,447,455,457,458,133],{},[40,454,124],{},[116,456,129],{}," block and snap it to the ",[116,459,118],{},[47,461,110,462,447,464,467,468,470,471,474],{},[40,463,148],{},[116,465,466],{},"Set Led"," block and snap it within the ",[116,469,129],{}," block. It will be set to ",[40,472,473],{},"on"," by default.",[47,476,110,477,447,479,457,482,485,486,216,489,158],{},[40,478,124],{},[116,480,481],{},"wait",[116,483,484],{},"Set Led on"," block. Change the ",[40,487,488],{},"1",[40,490,491],{},"0.5",[47,493,110,494,447,496,457,498,485,501,216,503,158],{},[40,495,148],{},[116,497,466],{},[116,499,500],{},"wait 0.5",[40,502,473],{},[40,504,505],{},"off",[47,507,110,508,447,510,457,512,485,515,216,517,158],{},[40,509,124],{},[116,511,481],{},[116,513,514],{},"Set Led off",[40,516,488],{},[40,518,491],{},[18,520,521],{},[99,522],{"alt":523,"src":524},"The completed block code for the blinking LED","\u002Flearn\u002Fpicobricks\u002Fblinking-led\u002FCompletedCode.webp",[18,526,527],{},"We've now completed the code for our blinking LED.",[14,529,531,540,543],{"title":530},"Run it and watch",[73,532,533],{},[47,534,535,536,539],{},"Select the ",[40,537,538],{},"run"," button at the top of the code window.",[18,541,542],{},"Your LED should now blink on and off every half a second. 🎉",[18,544,545],{},[99,546],{"alt":547,"src":548},"The LED blinking on and off every half a second","\u002Flearn\u002Fpicobricks\u002Fblinking-led\u002FBlinkingLED.gif",[14,550,551],{"title":259},[261,552,553],{},[18,554,555,557,558,560,561,564,565,567],{},[40,556,267],{}," Can you make your LED blink faster or slower? Try changing both ",[116,559,500],{}," blocks to a smaller number like ",[116,562,563],{},"0.1"," for a speedy flash, or a bigger number like ",[116,566,488],{}," for a slow, sleepy blink. What happens if you give the two waits different numbers?",[14,569,570],{"title":278},[280,571,572,580],{},[283,573,574],{},[286,575,576,578],{},[289,577,291],{},[289,579,294],{},[296,581,582,590,607,626],{},[286,583,584,587],{},[301,585,586],{},"The LED isn't lighting up at all",[301,588,589],{},"Check the USB cable is pushed in properly at both ends, and make sure the Brick IDE shows it's connected to your PicoBricks board.",[286,591,592,595],{},[301,593,594],{},"The blocks won't snap together",[301,596,597,598,600,601,603,604,606],{},"Make sure each block is dropped just inside the one above it. The ",[116,599,466],{}," and ",[116,602,481],{}," blocks need to sit inside the ",[116,605,129],{}," loop, not below it.",[286,608,609,612],{},[301,610,611],{},"The LED comes on but never turns off",[301,613,614,615,617,618,620,621,623,624,133],{},"Check your second ",[116,616,466],{}," block is set to ",[40,619,505],{},", and that a ",[116,622,481],{}," block sits after each ",[116,625,466],{},[286,627,628,631],{},[301,629,630],{},"Nothing happens when I press run",[301,632,633,634,636],{},"Try reconnecting the board, then press ",[40,635,538],{}," again. Unplugging the USB cable and plugging it back in often helps too.",{"title":343,"searchDepth":344,"depth":344,"links":638},[],"\u002Flearn\u002Fpicobricks\u002Fblinking-led\u002Fcover-blink.png",[351,352,353,354],{},"\u002Flearn\u002Fpicobricks\u002Fblinking-led","\u002Flearn\u002Fpicobricks\u002Fblink-project\u002Fblink-project.pdf",{"title":368,"description":343},"learn\u002Fpicobricks\u002Fblinking-led\u002Findex","https:\u002F\u002Fyoutu.be\u002FiaCOzFQv5NY","TP7wi7qCgj8J-JrrB6vHskJHxBFwfneUlINmA2p6gW0",{"id":649,"title":650,"body":651,"description":343,"draft":346,"duration":900,"extension":348,"image":901,"kit":902,"language":355,"level":356,"meta":905,"navigation":358,"path":906,"pdf":907,"platform":361,"seo":908,"stem":909,"youtube":910,"__hash__":911},"tutorials\u002Flearn\u002Fpicobricks\u002Fcontrolling-a-servo-motor\u002Findex.md","Controlling a Servo Motor",{"type":8,"value":652,"toc":898},[653],[11,654,655,687,691,696,708,737,820,835,844],{},[14,656,657,673],{"title":16},[18,658,659,660,664,665,669,670,672],{},"In this tutorial we're going to control a ",[22,661,663],{"slug":662},"servo-motor","servo motor"," using the ",[22,666,668],{"slug":667},"motor-controller","motor controller"," on the ",[22,671,118],{"slug":361}," board.",[33,674,675,679],{"color":35,"icon":36},[18,676,677],{},[40,678,42],{},[44,680,681,684],{},[47,682,683],{},"How to connect a servo motor to the PicoBricks through the motor controller.",[47,685,686],{},"How to control the servo motor through code.",[14,688,689],{"title":58},[60,690],{},[14,692,693],{"title":64},[66,694],{"terms":695},"servo-motor,motor-controller,picobricks,forever-loop",[14,697,699,702],{"title":698},"Wire up the servo motor",[18,700,701],{},"Connect the servo motor to the top connector of the motor controller with the yellow wire on the left pin. There's also a jumper across three pins. Make sure it's set for the servo motor, which means the jumper should be pushed as far left as it can go.",[18,703,704],{},[99,705],{"alt":706,"src":707},"Servo motor wiring diagram","\u002Flearn\u002Fpicobricks\u002Fcontrolling-a-servo-motor\u002Fwiring-diagram.webp",[14,709,710,731],{"title":71},[73,711,712,714,725],{},[47,713,88],{},[47,715,716,717,721,722,158],{},"Open your favourite web browser (we recommend Google Chrome or Microsoft Edge), go to ",[79,718,84],{"href":719,"rel":720},"https:\u002F\u002Fide.picobricks.com",[83]," and select ",[40,723,724],{},"PicoBlockly",[47,726,727,728,95],{},"Connect the board to the coding environment by selecting the ",[40,729,730],{},"connect",[18,732,733],{},[99,734],{"alt":735,"src":736},"The PicoBlockly coding environment","\u002Flearn\u002Fpicobricks\u002Fcontrolling-a-servo-motor\u002Fcoding-environment.webp",[14,738,739,814],{"title":105},[73,740,741,748,756,778,788,807],{},[47,742,110,743,745,746,119],{},[40,744,113],{},". Drag a ",[116,747,118],{},[47,749,110,750,125,752,152,754,133],{},[40,751,124],{},[116,753,129],{},[116,755,118],{},[47,757,110,758,125,761,764,765,216,768,771,772,216,775,158],{},[40,759,760],{},"Motor",[116,762,763],{},"Set Servo M1 Angle 180"," block inside the forever block. Change ",[40,766,767],{},"M1",[40,769,770],{},"M2",", and change ",[40,773,774],{},"180",[40,776,777],{},"90",[47,779,110,780,125,782,784,785,133],{},[40,781,124],{},[116,783,481],{}," block under the ",[116,786,787],{},"Set Servo M2 Angle 90",[47,789,110,790,792,793,784,795,798,799,216,801,600,803,216,805,158],{},[40,791,760],{},". Add another ",[116,794,763],{},[116,796,797],{},"wait 1"," block. Change ",[40,800,767],{},[40,802,770],{},[40,804,774],{},[40,806,209],{},[47,808,110,809,125,811,813],{},[40,810,124],{},[116,812,481],{}," block under the `Set Servo M2 Angle 0` block.",[18,815,816],{},[99,817],{"alt":818,"src":819},"The completed servo motor code","\u002Flearn\u002Fpicobricks\u002Fcontrolling-a-servo-motor\u002Fcompleted-code.webp",[14,821,822,829],{"title":247},[18,823,824,825,828],{},"Now the code's finished, let's run it. Select the ",[40,826,827],{},"Run"," button at the top of the code area. You should see the little arm on the servo motor move between 90 and 0 degrees.",[18,830,831],{},[99,832],{"alt":833,"src":834},"The servo motor arm moving between 90 and 0 degrees","\u002Flearn\u002Fpicobricks\u002Fcontrolling-a-servo-motor\u002Fdemo.gif",[14,836,837],{"title":259},[261,838,839],{},[18,840,841,843],{},[40,842,267],{}," Can you make the arm wave? Try adding more `Set Servo` blocks with different angles (like 0, 45 and 90), with a `wait` block after each one. What happens if you make the `wait` times shorter? Does the arm move faster?",[14,845,846],{"title":278},[280,847,848,856],{},[283,849,850],{},[286,851,852,854],{},[289,853,291],{},[289,855,294],{},[296,857,858,866,874,882,890],{},[286,859,860,863],{},[301,861,862],{},"The servo isn't moving at all",[301,864,865],{},"Check the servo is on the top connector with the yellow wire on the left pin, and that the USB cable is plugged in properly.",[286,867,868,871],{},[301,869,870],{},"The servo twitches or buzzes but won't turn",[301,872,873],{},"Check the jumper is pushed fully to the left so it's set for the servo.",[286,875,876,879],{},[301,877,878],{},"The code won't run",[301,880,881],{},"Make sure you pressed the connect button and your board is connected in PicoBlockly before pressing Run.",[286,883,884,887],{},[301,885,886],{},"The arm only moves once, then stops",[301,888,889],{},"Check all your blocks are inside the forever loop so they keep repeating.",[286,891,892,895],{},[301,893,894],{},"The arm moves to the wrong place",[301,896,897],{},"Check you changed M1 to M2 on every block, and that your angles are set to 90 and 0.",{"title":343,"searchDepth":344,"depth":344,"links":899},[],"15 mins","\u002Flearn\u002Fpicobricks\u002Fcontrolling-a-servo-motor\u002Fservo-cover.png",[118,903,904],"Servo motor","USB to MicroUSB cable",{},"\u002Flearn\u002Fpicobricks\u002Fcontrolling-a-servo-motor","\u002Flearn\u002Fpicobricks\u002Fcontrolling-a-servo-motor\u002Fcontrolling-a-servo-motor.pdf",{"title":650,"description":343},"learn\u002Fpicobricks\u002Fcontrolling-a-servo-motor\u002Findex","https:\u002F\u002Fyoutu.be\u002FSVJ-3dk5TyU","im4RedqYYg08eFPm5MVHwKhelI505zhjb5GcPMRfOWQ",{"id":913,"title":914,"body":915,"description":343,"draft":346,"duration":900,"extension":348,"image":1213,"kit":1214,"language":355,"level":356,"meta":1216,"navigation":358,"path":1217,"pdf":1218,"platform":361,"seo":1219,"stem":1220,"youtube":1221,"__hash__":1222},"tutorials\u002Flearn\u002Fpicobricks\u002Fdimmable-led\u002Findex.md","Dimmable LED",{"type":8,"value":916,"toc":1211},[917],[11,918,919,944,948,953,975,1117,1131,1148],{},[14,920,921,933],{"title":16},[18,922,923,924,926,927,669,930,932],{},"In this tutorial we're going to use the ",[22,925,30],{"slug":29}," and the ",[22,928,929],{"slug":929},"potentiometer",[22,931,118],{"slug":361}," board to make a dimmable lighting system.",[33,934,935,939],{"color":35,"icon":36},[18,936,937],{},[40,938,42],{},[44,940,941],{},[47,942,943],{},"How to control the RGB LED using the potentiometer.",[14,945,946],{"title":58},[60,947],{},[14,949,950],{"title":58},[66,951],{"terms":952},"potentiometer,rgb-led,variable,forever-loop",[14,954,955,970],{"title":71},[73,956,957,959,966],{},[47,958,88],{},[47,960,716,961,721,964,158],{},[79,962,84],{"href":719,"rel":963},[83],[40,965,724],{},[47,967,727,968,95],{},[40,969,730],{},[18,971,972],{},[99,973],{"alt":735,"src":974},"\u002Flearn\u002Fpicobricks\u002Fdimmable-led\u002Fcoding-environment.webp",[14,976,977,1111],{"title":105},[73,978,979,985,992,1009,1018,1033,1045,1075,1084,1097],{},[47,980,110,981,745,983,119],{},[40,982,113],{},[116,984,118],{},[47,986,110,987,125,989,991],{},[40,988,124],{},[116,990,129],{}," block onto the `PicoBricks` block.",[47,993,110,994,997,998,1001,1002,125,1005,1008],{},[40,995,996],{},"Variables",". Select ",[40,999,1000],{},"Create variable"," and type ",[40,1003,1004],{},"Colour",[116,1006,1007],{},"set Colour to"," block inside the forever block.",[47,1010,110,1011,125,1013,152,1016,133],{},[40,1012,206],{},[116,1014,1015],{},"round",[116,1017,1007],{},[47,1019,110,1020,125,1022,152,1025,182,1027,185,1030,158],{},[40,1021,206],{},[116,1023,1024],{},"1 + 1",[116,1026,1015],{},[40,1028,1029],{},"+",[40,1031,1032],{},"x",[47,1034,110,1035,125,1037,152,1040,199,1042,1044],{},[40,1036,148],{},[116,1038,1039],{},"Read Potentiometer",[116,1041,1015],{},[40,1043,1032],{}," sign.",[47,1046,110,1047,1049,1050,152,1052,1054,1055,1057,1058,216,1060,1063,1064,216,1066,1069,1070,216,1072,158],{},[40,1048,206],{},". Snap another ",[116,1051,1024],{},[116,1053,1015],{}," block, after the ",[40,1056,1032],{},". Change the first ",[40,1059,488],{},[40,1061,1062],{},"255",", the ",[40,1065,1029],{},[40,1067,1068],{},"÷"," and the remaining ",[40,1071,488],{},[40,1073,1074],{},"65535",[47,1076,110,1077,125,1079,784,1082,133],{},[40,1078,30],{},[116,1080,1081],{},"Set RGB Led Colour R 255 G 255 B 255",[116,1083,1007],{},[47,1085,110,1086,125,1088,1090,1091,1094,1095,133],{},[40,1087,996],{},[116,1089,1004],{}," block into the ",[40,1092,1093],{},"R"," value of the ",[116,1096,226],{},[47,1098,1099,1100,1103,1104,600,1107,1110],{},"Do the same as ",[40,1101,1102],{},"step 9"," for the ",[40,1105,1106],{},"G",[40,1108,1109],{},"B"," values.",[18,1112,1113],{},[99,1114],{"alt":1115,"src":1116},"The completed dimmable LED code","\u002Flearn\u002Fpicobricks\u002Fdimmable-led\u002Fcompleted-code.webp",[14,1118,1119,1125],{"title":247},[18,1120,1121,1122,1124],{},"Now the code's finished, let's test it. Select the ",[40,1123,827],{}," button at the top of the code area. Turn the potentiometer to see the LED get brighter or dimmer, right down until it goes out, depending on which way you turn it.",[18,1126,1127],{},[99,1128],{"alt":1129,"src":1130},"The dimmable LED fading up and down as the potentiometer turns","\u002Flearn\u002Fpicobricks\u002Fdimmable-led\u002Fdemo.gif",[14,1132,1133],{"title":259},[261,1134,1135],{},[18,1136,1137,1139,1140,600,1142,1144,1145,1147],{},[40,1138,267],{}," Can you make your dial control just one colour? Try setting the ",[40,1141,1106],{},[40,1143,1109],{}," values to `0` and leave only the ",[40,1146,1093],{}," value linked to the potentiometer, so your knob fades a red glow from bright to off. Then have a go at swapping it to just green, or just blue. What happens if you mix two colours together?",[14,1149,1150],{"title":278},[280,1151,1152,1160],{},[283,1153,1154],{},[286,1155,1156,1158],{},[289,1157,291],{},[289,1159,294],{},[296,1161,1162,1173,1184,1200],{},[286,1163,1164,1167],{},[301,1165,1166],{},"The LED doesn't light up at all",[301,1168,1169,1170,1172],{},"Check PicoBricks is connected using the connect button at the top of the code area, then press ",[40,1171,827],{}," again.",[286,1174,1175,1178],{},[301,1176,1177],{},"The brightness doesn't change when you turn the dial",[301,1179,1180,1181,1183],{},"Check your `Read Potentiometer` block is inside the `round` block, just before the ",[40,1182,1032],{},", and that the maths reads `x 255 ÷ 65535`.",[286,1185,1186,1189],{},[301,1187,1188],{},"The colour looks wrong or flickers",[301,1190,1191,1192,1194,1195,600,1197,1199],{},"Make sure the same `Colour` variable is dropped into all three slots (",[40,1193,1093],{},", ",[40,1196,1106],{},[40,1198,1109],{},").",[286,1201,1202,1205],{},[301,1203,1204],{},"PicoBricks won't connect",[301,1206,1207,1208,1210],{},"Try a different USB cable or port, check you picked ",[40,1209,724],{},", and press the connect button again.",{"title":343,"searchDepth":344,"depth":344,"links":1212},[],"\u002Flearn\u002Fpicobricks\u002Fdimmable-led\u002Fcover.png",[118,1215,904],"Raspberry Pi Pico",{},"\u002Flearn\u002Fpicobricks\u002Fdimmable-led","\u002Flearn\u002Fpicobricks\u002Fdimmable-led\u002Fdimmable-led.pdf",{"title":914,"description":343},"learn\u002Fpicobricks\u002Fdimmable-led\u002Findex","https:\u002F\u002Fyoutu.be\u002Fu5CaiNAMwkI","to14oGJY2zhzvWMrPp7M4yYEtNdj-ZZnupyyzv1o6c4",{"id":1224,"title":1225,"body":1226,"description":343,"draft":346,"duration":900,"extension":348,"image":1541,"kit":1542,"language":355,"level":356,"meta":1543,"navigation":358,"path":1544,"pdf":1545,"platform":361,"seo":1546,"stem":1547,"youtube":1548,"__hash__":1549},"tutorials\u002Flearn\u002Fpicobricks\u002Ftemperature-monitoring\u002Findex.md","Temperature Monitoring",{"type":8,"value":1227,"toc":1539},[1228],[11,1229,1230,1258,1262,1267,1287,1424,1441,1465],{},[14,1231,1232,1244],{"title":16},[18,1233,1234,1235,1239,1240,158],{},"Within this PicoBricks tutorial we're going to use the ",[22,1236,1238],{"slug":1237},"temperature-sensor","temperature sensor"," to sense the temperature of the room you're in. The temperature is then outputted to the ",[22,1241,1243],{"slug":1242},"oled-screen","OLED screen",[33,1245,1246,1250],{"color":35,"icon":36},[18,1247,1248],{},[40,1249,42],{},[44,1251,1252,1255],{},[47,1253,1254],{},"How to sense the temperature of a room through code",[47,1256,1257],{},"How to output the temperature to the OLED screen",[14,1259,1260],{"title":58},[60,1261],{},[14,1263,1264],{"title":64},[66,1265],{":terms":1266},"temperature-sensor, oled-screen, forever-loop",[14,1268,1269,1282],{"title":71},[73,1270,1271,1276,1278],{},[47,1272,77,1273,85],{},[79,1274,84],{"href":81,"rel":1275},[83],[47,1277,88],{},[47,1279,91,1280,95],{},[40,1281,94],{},[18,1283,1284],{},[99,1285],{"alt":101,"src":1286},"\u002Flearn\u002Fpicobricks\u002Ftemperature-monitoring\u002FCodingEnvironment.webp",[14,1288,1289,1415,1421],{"title":105},[73,1290,1291,1297,1305,1315,1342,1361,1373,1397,1407],{},[47,1292,110,1293,447,1295,450],{},[40,1294,113],{},[116,1296,118],{},[47,1298,110,1299,447,1301,457,1303,133],{},[40,1300,124],{},[116,1302,129],{},[116,1304,118],{},[47,1306,110,1307,447,1310,467,1313,133],{},[40,1308,1309],{},"Display",[116,1311,1312],{},"Clear Screen Buffer",[116,1314,129],{},[47,1316,110,1317,447,1319,457,1322,485,1324,1327,1328,1063,1331,1327,1334,600,1337,216,1339,158],{},[40,1318,1309],{},[116,1320,1321],{},"Write Text to Screen",[116,1323,1312],{},[40,1325,1326],{},"X"," value to ",[40,1329,1330],{},"15",[40,1332,1333],{},"Y",[40,1335,1336],{},"10",[40,1338,118],{},[40,1340,1341],{},"Temperature:",[47,1343,110,1344,447,1346,457,1348,485,1351,1327,1353,926,1356,1327,1358,158],{},[40,1345,1309],{},[116,1347,1321],{},[116,1349,1350],{},"Write Text to Screen X 15 Y 10 \"Temperature:\"",[40,1352,1326],{},[40,1354,1355],{},"55",[40,1357,1333],{},[40,1359,1360],{},"30",[47,1362,110,1363,447,1365,1368,1369,155,1371,158],{},[40,1364,148],{},[116,1366,1367],{},"Read Temperature"," block and snap it onto the ",[116,1370,1321],{},[40,1372,118],{},[47,1374,110,1375,447,1377,457,1379,485,1382,1327,1384,1063,1387,1327,1389,600,1392,216,1394,158],{},[40,1376,1309],{},[116,1378,1321],{},[116,1380,1381],{},"Write Text to Screen X 55 Y 30 Read Temperature",[40,1383,1326],{},[40,1385,1386],{},"35",[40,1388,1333],{},[40,1390,1391],{},"50",[40,1393,118],{},[40,1395,1396],{},"Degrees",[47,1398,110,1399,447,1401,457,1404,133],{},[40,1400,1309],{},[116,1402,1403],{},"Show Screen Buffer",[116,1405,1406],{},"Write Text to Screen X 35 Y 50 \"Degrees\"",[47,1408,110,1409,447,1411,457,1413,133],{},[40,1410,124],{},[116,1412,481],{},[116,1414,1403],{},[18,1416,1417],{},[99,1418],{"alt":1419,"src":1420},"The completed block code for temperature monitoring","\u002Flearn\u002Fpicobricks\u002Ftemperature-monitoring\u002FTemperatureSensingCode.webp",[18,1422,1423],{},"We've now completed the code for our temperature monitor.",[14,1425,1426,1432,1435],{"title":530},[73,1427,1428],{},[47,1429,535,1430,539],{},[40,1431,538],{},[18,1433,1434],{},"You should now see the live temperature displayed on the OLED screen. 🎉",[18,1436,1437],{},[99,1438],{"alt":1439,"src":1440},"The live room temperature shown on the OLED screen","\u002Flearn\u002Fpicobricks\u002Ftemperature-monitoring\u002FTemperatureMonitoring.gif",[14,1442,1443],{"title":259},[261,1444,1445],{},[18,1446,1447,1449,1450,1453,1454,1457,1458,1461,1462,1464],{},[40,1448,267],{}," Can you make your project react to the temperature? Try adding an ",[40,1451,1452],{},"if statement"," so the screen shows a message like ",[116,1455,1456],{},"Too hot!"," when the temperature climbs above a number you choose (your ",[40,1459,1460],{},"threshold","). For an extra challenge, light up an ",[40,1463,394],{}," whenever the room gets warm.",[14,1466,1467],{"title":278},[280,1468,1469,1477],{},[283,1470,1471],{},[286,1472,1473,1475],{},[289,1474,291],{},[289,1476,294],{},[296,1478,1479,1490,1506,1526],{},[286,1480,1481,1484],{},[301,1482,1483],{},"PicoBricks won't connect, or the connect button stays greyed out",[301,1485,1486,1487,1489],{},"Check the USB cable is pushed in at both ends, click the ",[40,1488,94],{}," button at the top of the code area, and use Google Chrome or Microsoft Edge.",[286,1491,1492,1495],{},[301,1493,1494],{},"Nothing appears on the OLED screen",[301,1496,1497,1498,600,1500,1502,1503,1505],{},"Make sure your ",[116,1499,1312],{},[116,1501,1403],{}," blocks are in place, and that all your blocks are snapped inside the ",[116,1504,129],{}," loop.",[286,1507,1508,1511],{},[301,1509,1510],{},"The temperature shows once but never changes",[301,1512,1513,1514,1516,1517,1519,1520,1522,1523,1525],{},"Check the ",[116,1515,1367],{}," block is snapped into the ",[116,1518,1321],{}," block, and that a ",[116,1521,481],{}," block sits inside the ",[116,1524,129],{}," loop so it keeps refreshing.",[286,1527,1528,1531],{},[301,1529,1530],{},"The words overlap or sit in the wrong place",[301,1532,1533,1534,600,1536,1538],{},"Have a look at your ",[40,1535,1326],{},[40,1537,1333],{}," values, they set where each piece of text sits on the screen.",{"title":343,"searchDepth":344,"depth":344,"links":1540},[],"\u002Flearn\u002Fpicobricks\u002Ftemperature-monitoring\u002Fcover.png",[351,352,353,354],{},"\u002Flearn\u002Fpicobricks\u002Ftemperature-monitoring","\u002Flearn\u002Fpicobricks\u002Ftemperature-monitoring\u002Ftemperature-monitoring.pdf",{"title":1225,"description":343},"learn\u002Fpicobricks\u002Ftemperature-monitoring\u002Findex","https:\u002F\u002Fyoutu.be\u002FK-ZN9wmLokk","nP_35_koZP2VZhxq5kOiR51xt-uuSvLvdZAo9zJoVQA",{"id":1551,"title":1552,"body":1553,"description":343,"draft":346,"duration":347,"extension":348,"image":1814,"kit":1815,"language":355,"level":356,"meta":1816,"navigation":358,"path":1817,"pdf":1818,"platform":361,"seo":1819,"stem":1820,"youtube":1821,"__hash__":1822},"tutorials\u002Flearn\u002Fpicobricks\u002Fusing-the-button\u002Findex.md","Using the Button",{"type":8,"value":1554,"toc":1812},[1555],[11,1556,1557,1580,1584,1589,1609,1702,1722,1734],{},[14,1558,1559,1569],{"title":16},[18,1560,1561,1562,1565,1566,1568],{},"Within this guide we're going to use the push ",[22,1563,1564],{"slug":1564},"button"," to control an ",[22,1567,394],{"slug":393}," by coding our PicoBricks board.",[33,1570,1571,1575],{"color":35,"icon":36},[18,1572,1573],{},[40,1574,42],{},[44,1576,1577],{},[47,1578,1579],{},"How to control an LED using a button",[14,1581,1582],{"title":58},[60,1583],{},[14,1585,1586],{"title":64},[66,1587],{":terms":1588},"button, led, forever-loop, if-statement",[14,1590,1591,1604],{"title":71},[73,1592,1593,1598,1600],{},[47,1594,77,1595,85],{},[79,1596,84],{"href":81,"rel":1597},[83],[47,1599,88],{},[47,1601,91,1602,95],{},[40,1603,94],{},[18,1605,1606],{},[99,1607],{"alt":101,"src":1608},"\u002Flearn\u002Fpicobricks\u002Fusing-the-button\u002FCodingEnvironment.webp",[14,1610,1611,1693,1699],{"title":105},[73,1612,1613,1621,1629,1639,1647,1659,1673,1681],{},[47,1614,110,1615,1617,1618,1620],{},[40,1616,113],{},". Select and drag a ",[116,1619,118],{}," block to the code area and drop it.",[47,1622,110,1623,447,1625,457,1627,133],{},[40,1624,124],{},[116,1626,129],{},[116,1628,118],{},[47,1630,110,1631,1633,1634,1636,1637,133],{},[40,1632,163],{},". Select an ",[116,1635,168],{}," block and snap it inside the ",[116,1638,129],{},[47,1640,110,1641,1633,1643,1368,1645,133],{},[40,1642,163],{},[116,1644,178],{},[116,1646,181],{},[47,1648,110,1649,447,1651,1654,1655,199,1657,1044],{},[40,1650,148],{},[116,1652,1653],{},"Read Button"," block and snap it within the first blank space of the ",[116,1656,181],{},[40,1658,178],{},[47,1660,110,1661,447,1663,1665,1666,1668,1669,216,1671,158],{},[40,1662,206],{},[116,1664,209],{}," block and snap it in the blank space after the ",[40,1667,178],{}," sign. Change the ",[40,1670,209],{},[40,1672,488],{},[47,1674,110,1675,447,1677,467,1679,133],{},[40,1676,148],{},[116,1678,484],{},[116,1680,181],{},[47,1682,110,1683,447,1685,467,1687,485,1689,216,1691,158],{},[40,1684,148],{},[116,1686,484],{},[116,1688,238],{},[40,1690,473],{},[40,1692,505],{},[18,1694,1695],{},[99,1696],{"alt":1697,"src":1698},"The completed block code for the button-controlled LED","\u002Flearn\u002Fpicobricks\u002Fusing-the-button\u002FCompletedButtonCode.webp",[18,1700,1701],{},"We've now completed the code for our button-controlled LED.",[14,1703,1704,1713,1716],{"title":530},[73,1705,1706,1710],{},[47,1707,535,1708,539],{},[40,1709,538],{},[47,1711,1712],{},"Press the button on your PicoBricks board.",[18,1714,1715],{},"When the button is pressed you should see the LED turn on, and switch off again when you let go. 🎉",[18,1717,1718],{},[99,1719],{"alt":1720,"src":1721},"The LED turning on while the button is pressed","\u002Flearn\u002Fpicobricks\u002Fusing-the-button\u002FUsingTheButtonDemo.gif",[14,1723,1724],{"title":259},[261,1725,1726],{},[18,1727,1728,1730,1731,1733],{},[40,1729,267],{}," Now you can switch a light on with a button, what else could you control? Try swapping a ",[116,1732,466],{}," block for a different brick, like making the buzzer beep while the button is held down. Can you get two things to happen from one press?",[14,1735,1736],{"title":278},[280,1737,1738,1746],{},[283,1739,1740],{},[286,1741,1742,1744],{},[289,1743,291],{},[289,1745,294],{},[296,1747,1748,1762,1778,1800],{},[286,1749,1750,1753],{},[301,1751,1752],{},"The LED doesn't come on when I press the button",[301,1754,1755,1756,1516,1758,199,1760,1044],{},"Check the USB cable is pushed in at both ends and that the Brick IDE shows it's connected to your PicoBricks board. Then check the ",[116,1757,1653],{},[116,1759,181],{},[116,1761,178],{},[286,1763,1764,1767],{},[301,1765,1766],{},"The LED stays on all the time",[301,1768,1769,1770,600,1772,1774,1775,1777],{},"Look at your ",[116,1771,181],{},[116,1773,238],{}," blocks and make sure the right ",[116,1776,466],{}," block sits inside each one, so the light knows when to switch on and when to switch off.",[286,1779,1780,1782],{},[301,1781,594],{},[301,1783,1784,1785,1787,1788,1790,1791,1194,1793,600,1795,1797,1798,158],{},"Drop each block just inside the one above it. The ",[116,1786,168],{}," block needs to sit inside the ",[116,1789,129],{}," loop, and the ",[116,1792,1653],{},[116,1794,178],{},[116,1796,209],{}," blocks all tuck into the top of the ",[116,1799,181],{},[286,1801,1802,1804],{},[301,1803,630],{},[301,1805,1806,1807,1809,1810,636],{},"Reconnect the board using the ",[40,1808,94],{}," button at the top of the code area, then press ",[40,1811,538],{},{"title":343,"searchDepth":344,"depth":344,"links":1813},[],"\u002Flearn\u002Fpicobricks\u002Fusing-the-button\u002Fcover.png",[351,352,353,354],{},"\u002Flearn\u002Fpicobricks\u002Fusing-the-button","\u002Flearn\u002Fpicobricks\u002Fusing-the-button\u002Fusing-the-button.pdf",{"title":1552,"description":343},"learn\u002Fpicobricks\u002Fusing-the-button\u002Findex","https:\u002F\u002Fyoutu.be\u002FHGowhuRMlRM","MApG1ETjhw88wwKf926ynKFGkMPsPvNqLH-ETMn-fOM",1785347039342]