HC_SR04 et programmation BLOCKlY

lchastain

New Member
bonjour,
j'utilise avec des collégiens la carte CHi035 dans le cadre d'un projet robotique. Je n'arrive pas à utiliser le capteur Ultrason HC-SR04 avec le logiciel de programmation graphique Blockly pour picaxe ?
branchements :
trigger sur B3
echo sur C7

mon programme : un moteur tourne dans un sens et doit s'arrêter lorsque le capteur détecte un obstacle à partir de 10cm.

test_ultrason_chi035.png

merci d'avance
lchastain
 

PieM

Senior Member
bonjour,
j'utilise avec des collégiens la carte CHi035 dans le cadre d'un projet robotique. Je n'arrive pas à utiliser le capteur Ultrason HC-SR04 avec le logiciel de programmation graphique Blockly pour picaxe ?
branchements :
trigger sur B3
echo sur C7

mon programme : un moteur tourne dans un sens et doit s'arrêter lorsque le capteur détecte un obstacle à partir de 10cm.

View attachment 20271

merci d'avance
lchastain

Bonjour, problème de logique !
si A < 10 vous mettez A à 0 mais 20ms après vous remettez A à 1.
utiliser si .. alors ...sinon
 

lchastain

New Member
merci

j'ai essayé le suivant et n'obtiens pas plus de résultat ?

test_ultrason_chi035.png

il faudrait peut être que j'essaie en avec un programme en BASIC....
 

PieM

Senior Member
Il y a visiblement un bug sous blocky !

le soit disant "distance US en mode 2 broches" est traduit en fait par la commande ULTRA qui correspond au mode 1 broche d'après la doc :

The 'ultra' command calculates the distance to an obstacle using the SRF005 ultrasonic range finder (distance sensor).
The SRF005 module should be wired for "mode 2" operation (with pin 4 to 0V) so that it uses a single pin for both trigger and echo. This is described in the SRF005 datasheet.


mais blocky traduit en :

Code:
[COLOR=Black]main:
   [/COLOR][COLOR=Blue]do
   [/COLOR][COLOR=#ff0000][B]ultra B.3, C.7, varA[/B][/COLOR][COLOR=Purple]
   [/COLOR][COLOR=Blue]if [/COLOR][COLOR=Black]varA [/COLOR][COLOR=DarkCyan]> [/COLOR][COLOR=Navy]10 [/COLOR][COLOR=Blue]then
      high B.0
   else
      low B.0
   endif
   loop
   stop[/COLOR]
 

Technical

Technical Support
Staff member
This is not a bug - 'ultra' command supports both 1 and 2 pin modes of the SRF005

ultra pin, var

ultra pin, pin, var

There are two different Blockly blocks - one for each mode.
CaptureUltra.PNG
 

lchastain

New Member
thanks technical
but i want to test with a hc- SR04.
in your picture i see that trigger is plugged to input pin C0 ....i I thought it had to be plugged to an output. Can you explain it to me please.
 

Technical

Technical Support
Staff member
With the 18M2 chip C.0 can be an output. However if you want to use a B.x pin that is also fine, just select the pin you wish to use.
 
Top