Workinmanva Posted May 17, 2015 Posted May 17, 2015 Hello I'm building a robot using scratchgpio7. I'm trying to install the ultra sonic sensor to prevent it from hitting the wall when my son gets to crazy with the controls. In the sense blocks there is no sonar23 option only pin 23. I tried using If pin23 sense = 0 To stop the motors. This did not seem to work. The line of code looked like this: Pin11-100 Pin13-100 Wait 1 sec If Pin23 Sensor value =5 (also tired =0) Wait .18 sec Pin11-0 Pin13-0 Pin11-0 Pin13-0 Stop script I wired it up as per Simons wiring diagram on his wed site using a single pin. I hope this makes some sense.
SimpleSi Posted May 20, 2015 Posted May 20, 2015 Hi looking at what you posted, I'd say your using your own motor controller board? if so, you need to create two variables called power11 and power13 and then set those values between 0 to 100 to vary the speed of the motors. If you've wired up you ultrasonic with the 3 resistors like Ultrasonic Sensor | Cymplecy (Simplesi) and connected to pin23 then jsut use the broadcast sonar23 wait 1 and then read the sonar23 sensor value (just tick the little box next to it to see its value displayed on the screen http://snag.gy/12jT3.jpg regards Simon
Workinmanva Posted June 26, 2015 Author Posted June 26, 2015 (edited) Robot 2 Hello everyone Thanks for the help Simon. I finally got the ultra sonic sensor working. The weird thing is the SENSOR23 code only shows up randomly in the sensor blocks. I wanted to show off some pics and a list of the hardware I used to build my scratchGPIO robot. I'm running Scratch GPIO7 and also using Motion-mmal to operate the raspi cam. So far very thing works great. Hardware: Raspberry pi A+ (running scratch) Raspberry pi A+ (Running Motion-mmal) Drok H-Bridge Turtle robot chasis Custom double deck 1/8 plexi glass top Vilros wifi adapter Pi Hut wifi adapter 5volt power supply (Anker 2nd Gen Astro) 5volt power supply Ultra sonic sensor (Sun Founder) HC-SR04 Mallofusa pan and tilt servo assembly MG995 servos Bread board power strip Bread board 7.5 volt motor/accessory power supply w/ 2300 ma rechargeables Raspberry pi camera module 12" camera module ribon Dual 10mm clear LED lights w/ custom machined mounting bracket 3mm station kit Micl. Nylon spacers and hardware Micl. Wires, jumper leads, and resistors 8 gig micro SD cards running NOOBS Software: ScratchGPIO7 Motion-mmal Both Pi's running: VNC, and Static IP Addresses Thanks for lookin Sean Edited June 26, 2015 by Workinmanva
SimpleSi Posted June 26, 2015 Posted June 26, 2015 (edited) Wow - an impressive machine Sonar23 will not show up as a sensor until you've done a broadcast sonar23. Its a chicken/egg situation Scratch doesn't know about any ultrasonics until you use it You might want to use broadcast ultra23 instead. The difference is that once you've broadcast ultra23, then ScratchGPIO will automatically do a reading every second and silently update the sensor value (ultra23) So if 1 sec intervals are short enough, it saves having to keep on pinging Simon Edited June 26, 2015 by SimpleSi
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now