Petit site pour ceux qui bricolent en électronique en général et sur les PICAXES en particulier. Les PICAXES sont des microprocesseurs (PIC de Microship) programmables en BASIC. Pleins de qualités, pas chers, ultra faciles à programmer. Tout (ou presque) est sur le site du distributeur Gotronic (voir les liens). Les pages seront ajoutées ou modifiées petit à petit. Dans le but d'améliorer ce blog, communiquez moi vos remarques et les erreurs que vous pouvez constater. Pour me contacter: Envoyez un mail à l'adresse : mag1mic@free.fr . Tout message reçoit une réponse Pour retourner au menu, Cliquer sur "LISTE DES PAGES", ici ou en haut de la colonne de gauche Pour laisser un message, allez dans le "LIVRE D'OR" Bonne visite
The Magic SwitchBox
"The Magic SwitchBox" est le titre qui permet d'acheter cette boite pour 130 ou 300 dollars...
On peut étonner ses amis pour beaucoup moins cher. Voici une vidéo du prototype proposé:
Bien sûr, la présentation est à améliorer, l'intérieur fait un peu fouillis:
Le truc est simple: Les couleurs n'ont aucun rôle dans ce tour de magie. Tout réside dans la manipulation des interrupteurs. En numérotant les leds et les inters de 1 à 4, en commençant à gauche: Ex: Si le dernier inter éteint est le 1 (à gauche), après un délai de 10s et sans aucune autre action sur les interrupteurs, la séquence suivante d'allumage des leds sera 1 - 2 - 3 - 4, indépendamment de l'ordre des interrupteurs actionnés. On choisit évidemment en premier l'interrupteur qui a la couleur de la led n°1, puis celui de la couleur de la led n°2, etc De même: Si le dernier inter éteint est le 2, la séquence sera 2 - 1 - 4 - 3 Si le dernier inter éteint est le 3, la séquence sera 3 - 4 - 1 - 2 Si le dernier inter éteint est le 4, la séquence sera 4 - 3 - 2 - 1
Regardez à nouveau la vidéo de démo, l'ordre des manipulations des interrupteurs est clairement visible, on peut mieux masquer la manipulation, et si on ne connait pas le truc, ce n'est pas évident. Autre détail: Si l'inter n°4 est sur ON à la mise sous tension, le système est bloqué, l'inter 1 allume la led1, etc
Le schéma: Celui de Bill Brown (qu'il faut remercier), utilise un picaxe 14M2 (l'original utilisait un 18M obsolète), j'ai simplement remplacé les résistances de pulldown sur les ineterrupteurs par les pullup internes. Le 0 sur les entrées ne correspond plus à l'ouverture, mais à la fermeture du contact. J'ai également remplacé le comptage de boucles par la commande time, il est ainsi très facile d'ajuster le "time out" pour modifier ce délai 10s Le découplage est réduit à un 100nF
Le picaxe est glissé, roulé en boule dans le petit emplacement, à côté de l'inter à glissière du boitier de pile. Les fils et le 100nF céramique sont soudés directement sur les pattes repliées du 14M2. Les 330ohms sont à l'extérieur, mais il serait plus "classe" de se fabriquer les lampes à vis, avec une 330 cms et une led coiffée par une boule de couleur (peinture à vitre ?) . Quoique, les capuchons de surligneurs...c'est plus rapide.
Y a pas la place pour l'arduino là
Un lien vers ce boitier comportant un inter et un petit logement qui fait bien l'affaire ici Le fil jaune, c'est la broche "serial in" pour modifier le programme sans sortir le picaxe.
Le programme, adapté au picaxe 14M2 par Bill Brown #picaxe 14m2 #no_data ' Magic Switchboard - original source by "Technical" from PicAxe Forum ' Modified for PicAxe 18x by Wayne Thomason of Addison, TX USA ' 7/15/2009 ' Modified for Picaxe 14m2 By Bill Brown ' 12/8/2012' ' mods: 1. Now is easily configurable via switch? and bulb? variables ' 2. "timeout" functions even without learning all 4 switches ' 3. starting point and sequence direction dependent on last switch turned off ' 4. Now has Audience_lockdown feature. If power is turned on while switch-4 ' is set, each light will respond only to corresponding switch position ' until circuit is reset. ' Modifs MM pullup sur C.0 à C.3 et timeout par ft time en s (30/09/2017) ' Assumptions ' 1. Times out after 10 seconds of all switches in the off position ' regardless of whether all switches are learned yet ' 2. All switches must be off at start ' (If switch 4 on when started, it starts up in audience-mode.) ' 3. All 4 switches must be switched on before that sequence is learned ' 4. Set bulb/LED outputs using bulb1, bulb2, bulb3 & bulb4 ' 5. Set switch inputs using switch1, switch2, switch3 and switch4 ' 6. first pattern is left to right, bulbs 1, 2, 3, 4 ' 7. subsequent patterns are determined by last SWITCH turned off: ' Switch 1 = 1234 order (bulb 1 first, then right in sequence) ' Switch 2 = 2143 order (bulb 2 first, then left in sequence, wrapping after first) ' Switch 3 = 3412 order (bulb 3 first, then right in sequence, wrapping after last) ' Switch 4 = 4321 order (bulb 4 first, then left in sequence)
symbol switch1 = pinc.3 ' input pin for switch 1 (pinc.0, pinc.1, pinc.2 and pinc.3) symbol switch2 = pinc.2 ' input pin for switch 2 symbol switch3 = pinc.1 ' input pin for switch 3 symbol switch4 = pinc.0 ' input pin for switch 4 symbol bulb1 = b.3 ' output for bulb 1 (b.0, b.1, b.2 and b.3) symbol bulb2 = b.2 ' output for bulb 2 symbol bulb3 = b.1 ' output for bulb 3 symbol bulb4 = b.0 ' output for bulb 4 symbol timeout = 9 ' comptage des s par time symbol flags = b0 ' flags to remember whether a switch has been learnt yet symbol flag0 = bit0 symbol flag1 = bit1 symbol flag2 = bit2 symbol flag3 = bit3 symbol light0 = b1 ' variable to remember which switch is which light symbol light1 = b2 symbol light2 = b3 symbol light3 = b4 symbol bulb = b7 symbol starting_lite = b6 ' variable to set starting light position (and direction) symbol position = b5 ' position counter dirsB=%111111 pullup %111100000000 ; R pullup sur C.0 à C.3 . Modif câblage:au repos switch OFF -> niveau haut
if switch4=1 then audience_lockdown
starting_lite = 1 ' Start of program do_reset: ' ' reset position counter if starting_lite = 1 then ' if starting with bulb 1, position reset to 0. position = 0 end if if starting_lite = 2 then ' if starting with bulb 2, position reset to 1. position = 1 end if if starting_lite = 3 then ' if starting with bulb 3, position reset to 2. position = 2 end if if starting_lite = 4 then ' if starting wtih bulb 4, position reset to 3. position = 3 end if
flags = 0 ' reset flags
' Learning loop waiting_to_learn_loop: ' if not learnt switch learn it if switch1 = 1 and flag0 = 0 then learn0 if switch2 = 1 and flag1 = 0 then learn1 if switch3 = 1 and flag2 = 0 then learn2 if switch4 = 1 and flag3 = 0 then learn3
' we have learnt that switch so light output accordingly if flag0 = 1 then if switch1 = 1 then high light0 else low light0 end if end if if flag1 = 1 then if switch2 = 1 then high light1 else low light1 end if end if
if flag2 = 1 then if switch3 = 1 then high light2 else low light2 end if end if
if flag3 = 1 then if switch4 = 1 then high light3 else low light3 end if end if
if switch2=0 and switch1=0 and switch3=0 and switch4=0 then ' count down to timeout even while in learning loop if time > timeout then do_reset else time=0 end if
goto waiting_to_learn_loop
' Learn a light position and set flag so we know that switch is done learn0: gosub bulbset ' position gives you the output for this switch flag0 = 1 ' set flag light0 = bulb ' remember position for this switch goto learn_end
learn1: gosub bulbset ' position gives you the output for this switch flag1 = 1 ' set flag light1 = bulb ' remember position for this switch goto learn_end
learn2: gosub bulbset ' position gives you the output for this switch flag2 = 1 ' set flag light2 = bulb ' remember position for this switch goto learn_end
learn3: gosub bulbset ' position gives you the output for this switch flag3 = 1 ' set flag light3 = bulb ' remember position for this switch 'goto learn_end
learn_end:
if starting_lite = 1 then 'if starting with 1st lamp, sequence = 1-2-3-4 inc position if position > 3 then have_learnt_all goto waiting_to_learn_loop end if
if starting_lite = 2 then 'if starting with 2nd lamp, sequence = 2-1-4-3 if position > 0 then 'don't dec if position=0, will cause error dec position else position = 3 'position was 0 before dec, set to "3" end if if position = 1 then have_learnt_all 'if position=1 then we have come full circle goto waiting_to_learn_loop 'not finished, loop and learn more switches end if
if starting_lite = 3 then 'if starting with 3rd lamp, sequence = 3-4-1-2 inc position if position > 3 then 'if position greater greater than 4th lamp, reset to "0" position = 0 end if if position = 2 then have_learnt_all 'if position=2 then we have come full circle goto waiting_to_learn_loop 'not finished, loop and learn more switches end if
if starting_lite = 4 then 'if starting with 4th lamp, sequence = 4-3-2-1 if position > 0 then 'don't dec if position=0, will cause error dec position else goto have_learnt_all 'position is "0", we have learned last position. end if goto waiting_to_learn_loop end if
; Toute manipulation sur les inters reset la variable time ; Si time >= timeout, la nouvelle séquence est validée.
have_learnt_all: if switch1 = 1 then high light0 time=0 else low light0 end if
if switch2 = 1 then high light1 time=0 else low light1 end if
if switch3 = 1 then high light2 time=0 else low light2 end if
if switch4 = 1 then high light3 time=0 else low light3 end if
'Set which bulb will start next round. (only if switches all learned) if b0 = 15 and switch1=1 and switch2=0 and switch3=0 and switch4=0 then ' if switch 1 on alone, set lamp 1 first starting_lite=1 end if
if b0 = 15 and switch1=0 and switch2=1 and switch3=0 and switch4=0 then ' if switch 2 on alone, set lamp 2 first starting_lite=2 end if
if b0 = 15 and switch1=0 and switch2=0 and switch3=1 and switch4=0 then ' if switch 3 on alone, set lamp 3 first starting_lite=3 end if
if b0 = 15 and switch1=0 and switch2=0 and switch3=0 and switch4=1 then ' if switch 4 on alone, set lamp 4 first starting_lite=4 end if
if time>timeout then do_reset goto have_learnt_all
bulbset: if position=0 then bulb = bulb1 end if
if position=1 then bulb = bulb2 end if
if position=2 then bulb = bulb3 end if
if position=3 then bulb = bulb4 end if return
audience_lockdown: if switch1 = 1 then high bulb1 else low bulb1 end if
if switch2 = 1 then high bulb2 else low bulb2 end if
if switch3 = 1 then high bulb3 else low bulb3 end if
if switch4 = 1 then high bulb4 else low bulb4 end if goto audience_lockdown