Help required with project plz! MIDI + Espruino + MIDI -> USB converter #4566
Replies: 1 comment
-
Posted at 2015-04-13 by DrAzzy Please be sure to only post your new thread once - somehow we got three copies of this (gordon will remove the extra copies next time he's online). Also, you need to include the full URL of the image you're trying to include. = undefined is shown when you run any command in the console that does not have a return value - this is standard javascript. It doesn't indicate any problem, unless you were expecting it to return something. Serial.write() does not include a linebreak. So under most circumstances, you should be able to:
into
or
Also, it's Math.round(), not round(). Posted at 2015-04-13 by alexanderbrevig How have you wired to the midi connector? Posted at 2015-04-13 by alexanderbrevig Also, have you seen the module for MIDI? Posted at 2015-04-14 by @gfwilliams Just copy + pasting the 2 posts from the other forum post: @allObjects' Post
Just to understand correctly This code..., is this what you have in the edit pane - right half view - of the Espruino Web IDE and you upload to Espruino? Instead providing the image reference as per your computer in the post format, please upload the image with the Upload a file link in the (edit) post widget. Because your image is accessible by given link, I assume from our code and description: Espruino execution complains about unknown references.... round is not a globally defined function, but a method (function) of the Math object (library). Change change this to: Next unknown reference is in line 22. (lower case) pot1, which is nowhere defined... and thought to have defined (upper case) Pot1 in line 17, and adjusted in line 19. Change lower case p in line 22 to upper case P. For line 20, add Btw: I assume you want to send values from 0..127 to your MIDI device. For that we need a slight adjustment of the calculation, for example Next unknown reference is the function readPot1 in line 26... Replace readPot1 by getAcc - or vice-versa. This will invoke getAcc() - or readPot1 - every 200 milliseconds the function that reads the value, adjusts it, and sends it to your device. Next thing to talk about is the sequence of onInit() and setInterval(). For development phase, the current sequence is ok: onInit() is invoked and then setInterval(); For IDE disconnected state though, you will save Espruino's state - see save() command in console pane - so that on (power on) reset (in IDE disconnected state), Espruino will run the complete code. On (power on) reset, Espruino will execute onInit() 'only' and thus - with current sequence - miss out on invoking setInterval(). Therefore, move your line 27. with the setInterval() as the last in your onInit() function (after line 10). What you are trying to send - with the given serial speed - has of course to fit into the 200 ms window... (plus some extra stuff, such reading the value, calculation, etc.). Assuming you have to send about 35 bits (max) - including start and stop bits and parity - you can decrease the interval down to - theoretically - 1..2 ms to get a more responsive behavior. With an interval so short, you may though make Espruino unavailable for other things you'd like it to do. Therefore, you will pick a compromise in reading interval from C0 and send only if the value has changed. But you keep that enhancement for a next development step - and experiment with success! PS: Did took a look a the MID message definitions... and wondered about what message(s) you want to send... (in the onInit() as well as in the getAcct() - or readPot1() ) . @loop's PostHello, Posted at 2015-04-14 by @gfwilliams Just to add to this, I think @allObjects has covered a lot of potential issues with your code. Right now Espruino doesn't warn you when you use an undefined variable, so it's quite easy to accidentally use the wrong one when you're not used to programming - especially as JavaScript is case sensitive. Posted at 2015-04-14 by ConnorHaynes Hi there, Thanks for your help guys, il post my diagram here now! Posted at 2015-04-14 by ConnorHaynes Posted at 2015-04-14 by ConnorHaynes For some reason i cannot upload the image, heres a written schematic.. for @AlexanderBrevig Espruino Pins: Pin C0 -> Pot1 (potentiometer 1) Pin B6 -> tx:/I+ (Midi to USB converter) Pin B8 -> Switch1 Thanks alot for you help @gfwilliams for that from the other forum, il have a go at this later to see if i can get it working when i have a chance to properly read through it. Does anyone know how i can get the switches working? Posted at 2015-04-14 by @allObjects What is the code you use for getting the switches' state? Depending how you connect your switches - pins B8 an dB9 against 3.3V or against GND grounbd, you have to set the pins' modes to either input_pulldown or input_pullup. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2015-04-13 by ConnorHaynes
Hi there,
Im looking for some help with coding for a project im working on if some kind soul could help me with it, as i am new to coding and dont really know how to make it work. Its prob very easy to do for someone who knows what they are doing,
Basically im trying to create a MIDI controller, although im having some difficulty coding the values to MIDI and sending it down the USB to MIDI converter. I have 2 pots and 2 switches to code. A kind friend give me the code for one of the pots although i cant seem to get it to work with the Espruino. The code is:
This code doesn't work for me for some reason- it keeps saying undefined. & I dont want to keep hassling my friend as he has helped me out loads to get to this point! Does someone know where i have gone wrong interpreting this code?
The potentiometers are Linear btw.
I have included a diagram of my wiring with my circuitry also to the Espruino.
I know this will be useful
http://www.midi.org/techspecs/midimessages.php
If anyone could help me out with the switches or getting the pots working (Or both!) i would be soo greatful! How would i get this to work does anyone know? All i have to do is get the right code from the Voltage value to be turned to MIDI and then send down the MIDI to USB converter to the computer.
Thank you!
Kind regards
Connor
Beta Was this translation helpful? Give feedback.
All reactions