ULTRASONIDOS:
{"name":"ultrasonidos","description":"","videoUrl":"","codeProject":false,"code":"/*** Included libraries ***/\n#include <BitbloqUS.h>\n#include
<SoftwareSerial.h>\n#include
<BitbloqSoftwareSerial.h>\n\n\n/***
Global variables and function definition ***/\nUS ultrasonidos_0( 3, 2);\nconst int
zumbador_0 = 11;\nbqSoftwareSerial puerto_serie_0( 0, 1, 9600);\n\nfloat
distancia = 0;\n\n\n\n/*** Setup ***/void setup(){\n\n}\n\n\n/*** Loop
***/void loop(){distancia = ultrasonidos_0.read();\npuerto_serie_0.print(\"d=\");\npuerto_serie_0.print(distancia);\npuerto_serie_0.println(\"c=\");\nif(distancia
< 40){tone(zumbador_0,261,100);\ndelay(100);\ndelay(distancia *
10);\n}\n}\n\n\n\n\n","image":"default","userTags":[],"hardwareTags":["bq
ZUM","us","buzz","sp"],"software":{"vars":{"name":"varsBloq","content":[[]],"enable":true,"childs":[{"name":"declareVariable","content":[[{"alias":"varInput","id":"NAME","value":"distancia"},{"alias":"bloqInput","bloqInputId":"VALUE","value":{"name":"number","content":[[{"alias":"numberInput","id":"VALUE","value":"0"}]],"enable":true}}]],"enable":true}]},"setup":{"name":"setupBloq","content":[[]],"enable":true,"childs":[]},"loop":{"name":"loopBloq","content":[[]],"enable":true,"childs":[{"name":"setVariable","content":[[{"alias":"dynamicDropdown","id":"NAME","value":"distancia","valueType":"float"},{"alias":"bloqInput","bloqInputId":"VALUE","value":{"name":"readSensor","content":[[{"alias":"dynamicDropdown","id":"SENSOR","value":"ultrasonidos_0","valueType":"float"}]],"enable":true}}]],"enable":true},{"name":"serialSend-v1","content":[[{"alias":"dynamicDropdown","id":"SERIAL","value":"puerto_serie_0"},{"alias":"bloqInput","bloqInputId":"DATA","value":{"name":"string","content":[[{"alias":"stringInput","id":"TEXT","value":"d="}]],"enable":true}},{"alias":"staticDropdown","id":"LN","value":"print"}]],"enable":true},{"name":"serialSend-v1","content":[[{"alias":"dynamicDropdown","id":"SERIAL","value":"puerto_serie_0"},{"alias":"bloqInput","bloqInputId":"DATA","value":{"name":"selectVariable","content":[[{"alias":"dynamicDropdown","id":"VAR","value":"distancia","valueType":"float"}]],"enable":true}},{"alias":"staticDropdown","id":"LN","value":"print"}]],"enable":true},{"name":"serialSend-v1","content":[[{"alias":"dynamicDropdown","id":"SERIAL","value":"puerto_serie_0"},{"alias":"bloqInput","bloqInputId":"DATA","value":{"name":"string","content":[[{"alias":"stringInput","id":"TEXT","value":"c="}]],"enable":true}},{"alias":"staticDropdown","id":"LN","value":"println"}]],"enable":true},{"name":"if","content":[[{"alias":"bloqInput","bloqInputId":"ARG1","value":{"name":"selectVariable","content":[[{"alias":"dynamicDropdown","id":"VAR","value":"distancia","valueType":"float"}]],"enable":true}},{"alias":"staticDropdown","id":"OPERATOR","value":"<"},{"alias":"bloqInput","bloqInputId":"ARG2","value":{"name":"number","content":[[{"alias":"numberInput","id":"VALUE","value":"40"}]],"enable":true}}]],"enable":true,"childs":[{"name":"buzzer","content":[[{"alias":"dynamicDropdown","id":"BUZZER","value":"zumbador_0"},{"alias":"staticDropdown","id":"NOTE","value":"261"},{"alias":"numberInput","id":"SECONDS","value":"100"}]],"enable":true},{"name":"waitAdvanced","content":[[{"alias":"bloqInput","bloqInputId":"TIME","value":{"name":"basicOperations","content":[[{"alias":"bloqInput","bloqInputId":"ARG1","value":{"name":"selectVariable","content":[[{"alias":"dynamicDropdown","id":"VAR","value":"distancia","valueType":"float"}]],"enable":true}},{"alias":"staticDropdown","id":"OPERATOR","value":"*"},{"alias":"bloqInput","bloqInputId":"ARG2","value":{"name":"number","content":[[{"alias":"numberInput","id":"VALUE","value":"10"}]],"enable":true}}]],"enable":true}}]],"enable":true}]}]}},"hardware":{"board":"bq
ZUM","robot":null,"connections":[{"pinSourceUid":"c93ba554-0d3d-4d69-9dd1-d0a984392bf9","pinTargetUid":"6be0dd9d-2e52-4b7d-9dfc-c9edad53bd10"},{"pinSourceUid":"75585395-6c15-433b-af22-9bd543f10507","pinTargetUid":"6be0dd9d-2e52-4b7d-9dfc-c9edad53bd11"},{"pinSourceUid":"fc8eb82e-bdda-44e7-a44f-67b5a82dcd69","pinTargetUid":"6be0dd9d-2e52-4b7d-9dfc-c9edad53bd02"},{"pinSourceUid":"ebb3992c-09f0-44bd-b51e-827f1500e6ca","pinTargetUid":"6be0dd9d-2e52-4b7d-9dfc-c9edad53bc05"}],"components":[{"id":"us","type":"US","width":120,"height":79,"dataReturnType":"float","pins":{"digital":["trigger","echo"]},"dragtype":"components","coordinates":{"x":74.70862470862471,"y":13.35559265442404},"category":"sensors","name":"ultrasonidos_0","connected":true,"uid":"fce82375-8982-4282-97bb-542412a2b71f","pin":{"trigger":"3","echo":"2"},"endpoints":{"trigger":{"uid":"c93ba554-0d3d-4d69-9dd1-d0a984392bf9","type":"digital"},"echo":{"uid":"75585395-6c15-433b-af22-9bd543f10507","type":"digital"}}},{"id":"buzz","type":"digital","width":85,"height":80,"pins":{"digital":["s"]},"dragtype":"components","coordinates":{"x":11.810344827586206,"y":10.818713450292398},"category":"buzzers","name":"zumbador_0","connected":true,"uid":"41aa3a70-26fe-417d-a11e-746ce2d3edab","pin":{"s":"11"},"endpoints":{"s":{"uid":"fc8eb82e-bdda-44e7-a44f-67b5a82dcd69","type":"digital"}}},{"id":"sp","baudRate":"9600","width":115,"height":71,"pin":{"s":"serial"},"pins":{"serial":["s"]},"dragtype":"components","coordinates":{"x":3.146853146853147,"y":56.594323873121866},"category":"serialElements","name":"puerto_serie_0","connected":true,"uid":"7f62e8e6-c1ba-42c7-aaf9-3188dcc9885f","endpoints":{"s":{"uid":"ebb3992c-09f0-44bd-b51e-827f1500e6ca","type":"serial"}}}]},"defaultTheme":"infotab_option_colorTheme","timesDownload":0,"timesAdded":0,"timesViewed":0,"bloqsVersion":"^0.4.24"}
LGB(programación sencilla para cambio de color cada varios segundos):
{"name":"lgb","description":"","videoUrl":"","codeProject":false,"code":"/*** Included libraries ***/\n\n\n/*** Global variables and function
definition ***/\nconst int rojo =
6;\nconst int azul_copy = 9;\nconst int verde = 4;\n\n\n\n\n/*** Setup
***/void setup(){\npinMode(rojo, OUTPUT);\npinMode(azul_copy,
OUTPUT);\npinMode(verde, OUTPUT);\n\n}\n\n\n/*** Loop
***/void loop(){digitalWrite(rojo,HIGH);\ndelay(2000);\ndigitalWrite(rojo,LOW);\ndigitalWrite(azul_copy,HIGH);\ndelay(2000);\ndigitalWrite(azul_copy,LOW);\ndigitalWrite(verde,HIGH);\ndelay(2000);\ndigitalWrite(verde,LOW);\n}\n\n\n\n\n","image":"default","userTags":[],"hardwareTags":["bq
ZUM","led"],"software":{"vars":{"name":"varsBloq","content":[[]],"enable":true,"childs":[]},"setup":{"name":"setupBloq","content":[[]],"enable":true,"childs":[]},"loop":{"name":"loopBloq","content":[[]],"enable":true,"childs":[{"name":"led","content":[[{"alias":"staticDropdown","id":"STATE","value":"HIGH"},{"alias":"dynamicDropdown","id":"LED","value":"rojo"}]],"enable":true},{"name":"wait","content":[[{"alias":"numberInput","id":"TIME","value":"2000"}]],"enable":true},{"name":"led","content":[[{"alias":"staticDropdown","id":"STATE","value":"LOW"},{"alias":"dynamicDropdown","id":"LED","value":"rojo"}]],"enable":true},{"name":"led","content":[[{"alias":"staticDropdown","id":"STATE","value":"HIGH"},{"alias":"dynamicDropdown","id":"LED","value":"azul_copy"}]],"enable":true},{"name":"wait","content":[[{"alias":"numberInput","id":"TIME","value":"2000"}]],"enable":true},{"name":"led","content":[[{"alias":"staticDropdown","id":"STATE","value":"LOW"},{"alias":"dynamicDropdown","id":"LED","value":"azul_copy"}]],"enable":true},{"name":"led","content":[[{"alias":"staticDropdown","id":"STATE","value":"HIGH"},{"alias":"dynamicDropdown","id":"LED","value":"verde"}]],"enable":true},{"name":"wait","content":[[{"alias":"numberInput","id":"TIME","value":"2000"}]],"enable":true},{"name":"led","content":[[{"alias":"staticDropdown","id":"STATE","value":"LOW"},{"alias":"dynamicDropdown","id":"LED","value":"verde"}]],"enable":true}]}},"hardware":{"board":"bq
ZUM","robot":null,"connections":[{"pinSourceUid":"5a552526-e8fc-43fe-b37a-4cecbfb86fc4","pinTargetUid":"6be0dd9d-2e52-4b7d-9dfc-c9edad53bd07"},{"pinSourceUid":"bf7714ea-5bbc-499f-afc0-e353430f5a75","pinTargetUid":"6be0dd9d-2e52-4b7d-9dfc-c9edad53bd04"},{"pinSourceUid":"6f6cbf25-45e4-48bd-9cb1-1efbe0be27d5","pinTargetUid":"6be0dd9d-2e52-4b7d-9dfc-c9edad53bd09"}],"components":[{"id":"led","width":55,"height":83,"pins":{"digital":["s"]},"dragtype":"components","coordinates":{"x":55.12820512820513,"y":3.5058430717863103},"category":"leds","name":"rojo","connected":true,"uid":"52d1946e-d716-4963-aac2-2a0a9a0cb500","pin":{"s":"6"},"endpoints":{"s":{"uid":"5a552526-e8fc-43fe-b37a-4cecbfb86fc4","type":"digital"}}},{"id":"led","width":55,"height":83,"pins":{"digital":["s"]},"dragtype":"components","coordinates":{"x":31.23543123543124,"y":7.846410684474124},"category":"leds","name":"azul_copy","connected":true,"uid":"250703d8-efa1-41f2-922e-e6737e606914","pin":{"s":"9"},"endpoints":{"s":{"uid":"bf7714ea-5bbc-499f-afc0-e353430f5a75","type":"digital"}}},{"id":"led","width":55,"height":83,"pins":{"digital":["s"]},"dragtype":"components","coordinates":{"x":80.53613053613053,"y":9.68280467445743},"category":"leds","name":"verde","connected":true,"uid":"3a05cf59-fb6f-4e19-b6a1-dfa528df6b79","pin":{"s":"4"},"endpoints":{"s":{"uid":"6f6cbf25-45e4-48bd-9cb1-1efbe0be27d5","type":"digital"}}}]},"defaultTheme":"infotab_option_colorTheme","timesDownload":0,"timesAdded":0,"timesViewed":0,"bloqsVersion":"^0.4.24"}
SENSOR ULTRASONIDOS
La página para aprender a programarlo es esta:
http://diwo.bq.com/programando-el-sensor-ultrasonido-en-bitbloq/
Proyecto reloj:
{"name":"reloj","description":"","videoUrl":"","codeProject":false,"code":"/*** Included libraries ***/\n#include
<SoftwareSerial.h>\n#include <BitbloqSoftwareSerial.h>\n#include
<Servo.h>\n\n\n/*** Global
variables and function definition
***/\nconst int led_0 = 10;\nbqSoftwareSerial puerto_serie_0( 0, 1,
9600);\nconst int zumbador_0 = 13;\nServo servo_continuo_0;\nServo
servo_continuo_1;\n\nfloat luz = 0;\n\n\n\n/*** Setup
***/void setup(){\npinMode(led_0,
OUTPUT);\nservo_continuo_0.attach(5);\nservo_continuo_1.attach(3);\n\n}\n\n\n/*** Loop
***/void
loop(){servo_continuo_0.write(180);\ntone(zumbador_0,329,20);\ndelay(20);\ndigitalWrite(led_0,HIGH);\ndelay(50);\nservo_continuo_0.write(90);\ndigitalWrite(led_0,LOW);\ndelay(59950);\nservo_continuo_0.write(180);\ntone(zumbador_0,349,20);\ndelay(20);\ndigitalWrite(led_0,HIGH);\ndelay(50);\nservo_continuo_0.write(90);\ndigitalWrite(led_0,LOW);\ndelay(59950);\n}\n\n\n\n\n","image":"default","userTags":[],"hardwareTags":["bq
ZUM","led","sp","buzz","servocont"],"software":{"vars":{"name":"varsBloq","content":[[]],"enable":true,"childs":[{"name":"declareVariable","content":[[{"alias":"varInput","id":"NAME","value":"luz"},{"alias":"bloqInput","bloqInputId":"VALUE","value":{"name":"number","content":[[{"alias":"numberInput","id":"VALUE","value":"0"}]],"enable":true}}]],"enable":true}]},"setup":{"name":"setupBloq","content":[[]],"enable":true,"childs":[]},"loop":{"name":"loopBloq","content":[[]],"enable":true,"childs":[{"name":"continuousServoStart","content":[[{"alias":"dynamicDropdown","id":"SERVO","value":"servo_continuo_0"},{"alias":"staticDropdown","id":"DIRECTION","value":"180"}]],"enable":true},{"name":"buzzer","content":[[{"alias":"dynamicDropdown","id":"BUZZER","value":"zumbador_0"},{"alias":"staticDropdown","id":"NOTE","value":"329"},{"alias":"numberInput","id":"SECONDS","value":"20"}]],"enable":true},{"name":"led","content":[[{"alias":"staticDropdown","id":"STATE","value":"HIGH"},{"alias":"dynamicDropdown","id":"LED","value":"led_0"}]],"enable":true},{"name":"wait","content":[[{"alias":"numberInput","id":"TIME","value":"50"}]],"enable":true},{"name":"continuousServoStop","content":[[{"alias":"dynamicDropdown","id":"SERVO","value":"servo_continuo_0"}]],"enable":true},{"name":"led","content":[[{"alias":"staticDropdown","id":"STATE","value":"LOW"},{"alias":"dynamicDropdown","id":"LED","value":"led_0"}]],"enable":true},{"name":"wait","content":[[{"alias":"numberInput","id":"TIME","value":"59950"}]],"enable":true},{"name":"continuousServoStart","content":[[{"alias":"dynamicDropdown","id":"SERVO","value":"servo_continuo_0"},{"alias":"staticDropdown","id":"DIRECTION","value":"180"}]],"enable":true},{"name":"buzzer","content":[[{"alias":"dynamicDropdown","id":"BUZZER","value":"zumbador_0"},{"alias":"staticDropdown","id":"NOTE","value":"349"},{"alias":"numberInput","id":"SECONDS","value":"20"}]],"enable":true},{"name":"led","content":[[{"alias":"staticDropdown","id":"STATE","value":"HIGH"},{"alias":"dynamicDropdown","id":"LED","value":"led_0"}]],"enable":true},{"name":"wait","content":[[{"alias":"numberInput","id":"TIME","value":"50"}]],"enable":true},{"name":"continuousServoStop","content":[[{"alias":"dynamicDropdown","id":"SERVO","value":"servo_continuo_0"}]],"enable":true},{"name":"led","content":[[{"alias":"staticDropdown","id":"STATE","value":"LOW"},{"alias":"dynamicDropdown","id":"LED","value":"led_0"}]],"enable":true},{"name":"wait","content":[[{"alias":"numberInput","id":"TIME","value":"59950"}]],"enable":true}]}},"hardware":{"board":"bq
ZUM","robot":null,"connections":[{"pinSourceUid":"5ec951e1-bad2-4040-84fa-ce0f9eec07af","pinTargetUid":"6be0dd9d-2e52-4b7d-9dfc-c9edad53bd03"},{"pinSourceUid":"2e0a3cc9-0c74-42bf-9c33-2a0f22748cde","pinTargetUid":"6be0dd9d-2e52-4b7d-9dfc-c9edad53bc05"},{"pinSourceUid":"43a41c89-b708-4ebd-a46c-bbd50c930de0","pinTargetUid":"6be0dd9d-2e52-4b7d-9dfc-c9edad53bd00"},{"pinSourceUid":"df6d4b55-fafb-43c7-8fc0-85c9d0646d35","pinTargetUid":"6be0dd9d-2e52-4b7d-9dfc-c9edad53bd08"},{"pinSourceUid":"b7b430b2-0d51-4002-9ce6-70ff1021cfa3","pinTargetUid":"6be0dd9d-2e52-4b7d-9dfc-c9edad53bd10"}],"components":[{"id":"led","width":55,"height":83,"pins":{"digital":["s"]},"dragtype":"components","coordinates":{"x":39.976689976689975,"y":1.5025041736227045},"category":"leds","name":"led_0","connected":true,"uid":"58146dc9-8a48-4a4b-823c-a985e26dd5b5","pin":{"s":"10"},"endpoints":{"s":{"uid":"5ec951e1-bad2-4040-84fa-ce0f9eec07af","type":"digital"}}},{"id":"sp","baudRate":"9600","width":115,"height":71,"pin":{"s":"serial"},"pins":{"serial":["s"]},"dragtype":"components","coordinates":{"x":11.188811188811188,"y":74.45742904841403},"category":"serialElements","name":"puerto_serie_0","connected":true,"uid":"a25903fa-01ba-4924-8158-66bd1358d109","endpoints":{"s":{"uid":"2e0a3cc9-0c74-42bf-9c33-2a0f22748cde","type":"serial"}}},{"id":"buzz","type":"digital","width":85,"height":80,"pins":{"digital":["s"]},"dragtype":"components","coordinates":{"x":9.324009324009324,"y":22.370617696160267},"category":"buzzers","name":"zumbador_0","connected":true,"uid":"9ae0aa05-4e17-4e83-a744-56d17b0afd91","pin":{"s":"13"},"endpoints":{"s":{"uid":"43a41c89-b708-4ebd-a46c-bbd50c930de0","type":"digital"}}},{"id":"servocont","width":125,"height":106,"pins":{"digital":["s"]},"dragtype":"components","coordinates":{"x":52.7972027972028,"y":75.18684603886398},"category":"continuousServos","name":"servo_continuo_0","connected":true,"uid":"c5cba151-54bc-4a23-ba8b-2a1662a74d3a","pin":{"s":"5"},"endpoints":{"s":{"uid":"df6d4b55-fafb-43c7-8fc0-85c9d0646d35","type":"digital"}}},{"id":"servocont","width":125,"height":106,"pins":{"digital":["s"]},"dragtype":"components","coordinates":{"x":79.02097902097903,"y":32.7212020033389},"category":"continuousServos","name":"servo_continuo_1","connected":true,"uid":"acb5bb92-6a0e-4c40-84f0-f71c38883b17","pin":{"s":"3"},"endpoints":{"s":{"uid":"b7b430b2-0d51-4002-9ce6-70ff1021cfa3","type":"digital"}}}]},"defaultTheme":"infotab_option_colorTheme","timesDownload":0,"timesAdded":0,"timesViewed":0,"bloqsVersion":"^0.4.24"}
KIT BQ.
PROYECTO 1:
/*** Included
libraries ***/
#include <SoftwareSerial.h>
#include <BitbloqSoftwareSerial.h>
/*** Global variables and function definition ***/
const int led_0 = 9;
bqSoftwareSerial puerto_serie_0( 0, 1, 9600);
const int sensor_de_luz_0 = A5;
float luz = 0;
/*** Setup ***/void setup(){
pinMode(led_0, OUTPUT);
pinMode(sensor_de_luz_0, INPUT);
}
/*** Loop ***/void loop(){luz = ;
puerto_serie_0.println(luz);
if(luz < 90){digitalWrite(led_0,HIGH);
}
else {digitalWrite(led_0,LOW);
}
}
#include <SoftwareSerial.h>
#include <BitbloqSoftwareSerial.h>
/*** Global variables and function definition ***/
const int led_0 = 9;
bqSoftwareSerial puerto_serie_0( 0, 1, 9600);
const int sensor_de_luz_0 = A5;
float luz = 0;
/*** Setup ***/void setup(){
pinMode(led_0, OUTPUT);
pinMode(sensor_de_luz_0, INPUT);
}
/*** Loop ***/void loop(){luz = ;
puerto_serie_0.println(luz);
if(luz < 90){digitalWrite(led_0,HIGH);
}
else {digitalWrite(led_0,LOW);
}
}
PROYECTO 2:
/*** Included
libraries ***/
#include <SoftwareSerial.h>
#include <BitbloqSoftwareSerial.h>
#include <Servo.h>
/*** Global variables and function definition ***/
bqSoftwareSerial puerto_serie_0( 0, 1, 9600);
Servo servo_0;
float angulo = 5;
/*** Setup ***/void setup(){
servo_0.attach(10);
}
/*** Loop ***/void loop(){servo_0.write(5);
delay(1000);
servo_0.write(45);
delay(1000);
servo_0.write(90);
delay(1000);
servo_0.write(135);
delay(1000);
}
#include <SoftwareSerial.h>
#include <BitbloqSoftwareSerial.h>
#include <Servo.h>
/*** Global variables and function definition ***/
bqSoftwareSerial puerto_serie_0( 0, 1, 9600);
Servo servo_0;
float angulo = 5;
/*** Setup ***/void setup(){
servo_0.attach(10);
}
/*** Loop ***/void loop(){servo_0.write(5);
delay(1000);
servo_0.write(45);
delay(1000);
servo_0.write(90);
delay(1000);
servo_0.write(135);
delay(1000);
}
No hay comentarios:
Publicar un comentario