Just a quick question for a project.
If I write a decimal to a digital pin would it output it as binary?
Just a quick question for a project.
If I write a decimal to a digital pin would it output it as binary?
A digital pin can only be on or off. How do you propose to write a decimal to it ?
Perhaps you could explain what you are trying to do.
Yes. It will output a high or low voltage depending on the value. You can't get more binary than that!
Sorry should have put more detail in.
I want to output binary to a pin. It would be easier for me to work with decimals so I can easily use variables as the values and do math.
Im trying to output MIDI data and I need to send 3 bytes for each message. I'm not using a library because its for a college project and I'm trying to score extra points. I'm outputting to a MIDI port and not over serial.
So, do you want to take a decimal number like 11 and output 1011 as 4 successive pulses or something else ? Please let's have more detail.
Just use software serial. It already handles all the hard work like timing.
I realised writing that last post that I might need to know something about the transfer rate. Nothing I have read mentioned it unless it was over USB with a baudrate of 31250bps.
OK so I have one pin on a MIDI port that I would like to send binary too. Each message consists of 3 bytes. So I would like to write a function that will output each byte individually from a decimal number. That way I can pass 3 variables to the function each time I want to use it.
If it comes down to it I could convert the decimal into binary before outputting as part of the function.
Ok I looked it up I need to transfer the binary at a baudrate of 31250bps. Surely there is a simple way to do this because I use libraries all the time that do it. I really dont want to use serial.
OK so I have one pin on a MIDI port that I would like to send binary too. Each message consists of 3 bytes. So I would like to write a function that will output each byte individually from a decimal number.
This is still a very mixed up explanation of what you want to do. You can only output 0 or 1 from a digital pin, nothing more, nothing less. It does not matter if what you want to output is decimal, a byte, in hex or even octal, a digital pin can only output 0 or 1.
You can break a byte down to 8 individual bits and output each of them in series but not a whole byte at a time.
Sorry guys I'm still a noob.
So an example would be the ShiftOut() found here...
http://www.arduino.cc/en/Reference/ShiftOut
You pass it the pins and the number would would like to output. Then it will pull the pins up and down for you.
What I want is simpler than this. I would like something like the SiftOut that I can give a Badrate, a pin number and a value. Then that "thing" will output that value as binary at that baud rate on that pin.
Also feel free to correct any of my terminology I'm still trying to learn.
MIDI REQUIRES a UART. It is not simply pumping bits out on a pin. There is framing - a start bit, and a stop bit - and the timing must be precise, within about 1%, or the MIDI device will not read the correct data. A true MIDI device also requires a current-driven input, and simply feeding it a TTL-level signal will not necessarily work reliably. Why are you not simply doing the obvious thing, and using a hardware UART, and a proper MIDI electrical interface?? ALL Arduinos have at least one, and most have several.
Regards,
Ray L.
RayLivingston:
MIDI REQUIRES a UART. It is not simply pumping bits out on a pin. There is framing - a start bit, and a stop bit - and the timing must be precise, within about 1%, or the MIDI device will not read the correct data. A true MIDI device also requires a current-driven input, and simply feeding it a TTL-level signal will not necessarily work reliably. Why are you not simply doing the obvious thing, and using a hardware UART, and a proper MIDI electrical interface?? ALL Arduinos have at least one, and most have several.Regards,
Ray L.
Wow cool you seem to know what your talking about. I'm just following this.
It said all I had to send was the command and data bytes.
I dont know what a UTAR is but will look it up.
UART is what makes the serial port work on the Uno. See section 20 of the '328P datasheet.
I might be over simplifying what I just read but could I just send the serial data from the tx pin into my data pin on my MIDI port?
Dont worry I have got it now. In the example I was looking at I thought he was using digital pin 1 because it was the only pin he had connected. But he was using it because it has tx.
Thanks guys I just learned a lot.