Switch case over 9 does not work

Found error in code, need to post once more.

Read the 'serial input basics - updated' thread.

'12' is not a character. You need to collect bytes from serial input and combine them into a character array. Next you can convert to an e.g. integer and use that in your switch statement.

On cellphone right now so can't help further.

To explain a little more

'1' is the character 1, not the number 1. If you check e.g. asciitable.com, it is stored in the computer as the number 49.

When you send the text "10" from e.g. to the arduino, it will first receive the '1' and next the '0'. So you need to collect. Now you also need a means to determine where your input ends; you can set up serial monitor to send a linefeed (newline) and test for that.

Note that when you have converted the final input to a number, you will not use e.g. [u]case '1'[/u] but [u]case 1:[/u]

Serial Input Basics - updated

Give it a try; you can always go back to your other approach ;)

Send the last 3 in hex:

// 10a -Motor 2 40 % // 11b -Motor 2 20 % // 12c -Motor 2 Stopp

Koprian19: I didnt quite understand. How will the code then look like?

Humans count from 0 to 9, computers count from 0 to 15 (there were exceptions in the past as far as I can recall). In hexadecimal that is represented by 0..9 followed by A..F (A=10, B=11, .., F=15).

Crossroads' suggestion is to use that. Counting like that can become a second nature if you use it often enough.

Koprian19: I already set Motor 2 parameters as q, w, e, r, t and y. Easier to control since they are paralell to eachother.

Keep it like that; it's easier to expand on ;)

Humans count from 0 to 9, computers count from 0 to 15

Strictly speaking, computers count from 0 to 1. The 0 to 15/F is just a compromise between what's convenient for humans and what's convenient for computers (because 0 to 15 represents exactly 4 bits, in other words 0000 to 1111).

PaulRB: Strictly speaking, computers count from 0 to 1. The 0 to 15/F is just a compromise between what's convenient for humans and what's convenient for computers (because 0 to 15 represents exactly 4 bits, in other words 0000 to 1111).

True - and some (too many) years ago, octal (0-7) was the norm. For the 8080 (see I am old!!), octal was very nice because most instructions consisted to the top two bits being the instruction, the next 3 bits was the destination and the bottom 3 bits was the source. You could quite easily (I did it all the time) hand assemble instructions (I even had a little cardboard "slide rule" device for calculating instructions !! ) Ah, those were the days. 4k was huge - why would I need more RAM than that? I still have one of these downstairs (they had one in HEX too) http://bugbookmuseum.blogspot.com/2013/03/vintage-micrcomputer-collector.html

I'm perhaps a little younger than you - I used 8085's - a bit quicker and only a single +5v psu..

it's amazing what you can do with a limited amount of code and RAM storage if that's all you have!

I also used PL/M as well as assembly, and had the huge luxury of an Intel MDS - the old 'blue box'..

very primitive by modern standards, but got the job done...

regards

Allan

I remember all those !! Remember the Z-80 when it first came out you could buy it from the full page ad in Byte Magazine (and others) for $149 for the CPU and manual? (and that was when people were lucky to make $3 / hour!) Nice chip, but a few quirks I learned to design around.

mikey

You guys make me feel so young. I started with the 8088, then jumped to the 286 with a 256 color monitor and a 10 Mb HDD no less :P

Sid

I had to deal with Motorola 6800/68000 exorciser when finishing Technical University ...

rpt007: exorciser

A ghost in the machine?

Eeee when I were a lad... I wrote z80 machine code directly in hex on Sinclair ZX81, 6502 assembler on Acorn BBC micro and Apple II, and 6809 on a Dragon 32. Those were the days! At Uni I wrote in assembler on a DEC LS11 which had 8" floppy disks!

A ghost in the machine?

Yes, Sir - also coming with those nice 8" floppy disks and 2 drives (called "0" and "1").

The Motorola EXORciser was a desktop computer built with the M6800 ICs that could be used for prototyping and debugging new designs.

Source: https://en.wikipedia.org/wiki/Motorola_6800

On this machine I did my engineering graduation work and one of my tasks was to make this machine talk to a FPLA programmer (serial communication interface which I had to program on assembler level ..).

PaulRB: A ghost in the machine?

Eeee when I were a lad... I wrote z80 machine code directly in hex on Sinclair ZX81, 6502 assembler on Acorn BBC micro and Apple II, and 6809 on a Dragon 32. Those were the days! At Uni I wrote in assembler on a DEC LS11 which had 8" floppy disks!

I think I still have a couple of the Sinclair's downstairs as well as my other Z80 (and even an 8080 - Morrows Microstuff front panel that allowed direct octal entry on a keypad and display - well ahead of it's time!!) as well as my DSDD 8 inch floppy drives too. Ah, CP/M - those were the days UCSD Pascal, hand assembled code for the tape drive etc (Kansas City Standard). Thrilled when I got an assembler and a C compiler !! I still have the old S-100 book around here that has all the specifications etc. for the signals. And 2mhz for a cpu clock was FAST !!! :)

hi

Hi to you too. We thought you would not be back until the new year, so we took a trip down memory lane. Now you updated/deleted your posts, which make us all look crazy. What can we do for you now?