{"id":829,"date":"2016-03-03T08:55:26","date_gmt":"2016-03-03T07:55:26","guid":{"rendered":"http:\/\/www.macerobotics.com\/?p=829"},"modified":"2016-03-03T11:22:36","modified_gmt":"2016-03-03T10:22:36","slug":"mrpi1-wake-up-alarm","status":"publish","type":"post","link":"https:\/\/www.macerobotics.com\/?p=829","title":{"rendered":"MRPi1 &#8211; Wake up alarm"},"content":{"rendered":"<p style=\"text-align: justify;\">Wake up alarm with MRPi1 robot. The robot stops the alarm automaticly when the robot detects the light.<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/JfOhWZ6FQds\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>Python program :<\/p>\n<pre><span style=\"color: #0000ff;\"><span style=\"color: #00ff00;\"># import mrpi1 lib<\/span>\r\nfrom mrpi1_lib import *<\/span>\r\n<span style=\"color: #0000ff;\">import time<\/span>\r\n\r\n<span style=\"color: #0000ff;\">try:\r\n<\/span>\r\n<span style=\"color: #0000ff;\">\u00a0 while 1:<\/span>\r\n<span style=\"color: #0000ff;\">\u00a0\u00a0\u00a0 al1 = ambiantLight(1) <span style=\"color: #00ff00;\"># read ambiant light,sensor 1<\/span><\/span>\r\n<span style=\"color: #0000ff;\">\u00a0\u00a0\u00a0 al2 = ambiantLight(2)<\/span>\r\n<span style=\"color: #0000ff;\">\u00a0\u00a0\u00a0 al3 = ambiantLight(3)<\/span>\r\n<span style=\"color: #0000ff;\">\u00a0\u00a0\u00a0 al4 = ambiantLight(4)<\/span>\r\n<span style=\"color: #0000ff;\">\u00a0\u00a0\u00a0 al5 = ambiantLight(5)<\/span>\r\n<span style=\"color: #0000ff;\">\u00a0\u00a0\u00a0 al6 = ambiantLight(6)<\/span>\r\n<span style=\"color: #0000ff;\">\u00a0\u00a0\u00a0 print \"Ambiant light = %d %d %d %d %d %d\" %(al1, al2, al3, al4, al5, al6)\r\n<\/span>\r\n<span style=\"color: #0000ff;\">\u00a0\u00a0\u00a0 if (al1 &lt; 4000 and al2 &lt; 4000): <span style=\"color: #00ff00;\"># light detects<\/span><\/span>\r\n<span style=\"color: #0000ff;\">\u00a0\u00a0\u00a0\u00a0 print \"end alarm\"<\/span>\r\n<span style=\"color: #0000ff;\">\u00a0\u00a0\u00a0\u00a0 writeCommand(\"SPD\")<span style=\"color: #00ff00;\"># disable speaker<\/span><\/span>\r\n<span style=\"color: #0000ff;\">\u00a0\u00a0\u00a0\u00a0 exit()<\/span>\r\n<span style=\"color: #0000ff;\">\u00a0\u00a0\u00a0 else:<\/span>\r\n<span style=\"color: #0000ff;\">\u00a0\u00a0\u00a0\u00a0\u00a0 playWav(\"alarmClock.wav\") <span style=\"color: #00ff00;\"># play alarm wav file<\/span><\/span>\r\n<span style=\"color: #0000ff;\">\u00a0\u00a0\u00a0 time.sleep(0.2)<\/span>\r\n\r\n<span style=\"color: #0000ff;\">except:<\/span>\r\n<span style=\"color: #0000ff;\">\u00a0 writeCommand(\"SPD\") <span style=\"color: #00ff00;\"># disable speaker<\/span><\/span>\r\n<span style=\"color: #0000ff;\">\u00a0 exit()<\/span>\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wake up alarm with MRPi1 robot. The robot stops the alarm automaticly when the robot detects the light. Python program : # import mrpi1 lib from mrpi1_lib import * import time try: \u00a0 while 1: \u00a0\u00a0\u00a0 al1 = ambiantLight(1) # read ambiant light,sensor 1 \u00a0\u00a0\u00a0 al2 = ambiantLight(2) \u00a0\u00a0\u00a0 al3 = ambiantLight(3) \u00a0\u00a0\u00a0 al4 = &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[10,9,15,7],"class_list":["post-829","post","type-post","status-publish","format-standard","hentry","category-mrpi1","tag-mobile-robot","tag-raspberry-pi","tag-raspberry-pi-robot","tag-robot"],"_links":{"self":[{"href":"https:\/\/www.macerobotics.com\/index.php?rest_route=\/wp\/v2\/posts\/829","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.macerobotics.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.macerobotics.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.macerobotics.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.macerobotics.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=829"}],"version-history":[{"count":5,"href":"https:\/\/www.macerobotics.com\/index.php?rest_route=\/wp\/v2\/posts\/829\/revisions"}],"predecessor-version":[{"id":838,"href":"https:\/\/www.macerobotics.com\/index.php?rest_route=\/wp\/v2\/posts\/829\/revisions\/838"}],"wp:attachment":[{"href":"https:\/\/www.macerobotics.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=829"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.macerobotics.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=829"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.macerobotics.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}