Jump to content

I have an arduino and I want to control what it's doing by sending it a value to it through serial between 0 and 7000 and from that decide what it needs to do. I have tried several things but none have worked what is the best way to do this. (the serial command could come at it at any time and it needs to be able to store it as a variable so I can do stuff with the variable)

 

what I want it do

 

C is set to a value

arduino doing X

serial comes in

arduino reads serial, and sets the variable V to equal the serial

arduino checks to confirm V is between 0 and 7000, and if it is sets C to equal V

arduino continues doing X which will include using C

 

I can get the code for all of this to work apart from the 

arduino reads serial

as it either completely ignores the serial command or it recognises it, but in a strange way (I have had 321 turn into 3, 2, 1, 0, 0, 0, 0 etc. and the other one I have had is 321 turned int 8, 3, 5, 0, 0, 0 ,0 etc. which is obviously not what I want it to do)

The owner of "too many" computers, called

The Lord of all Toasters (1920X 1080ti 32GB)

The Toasted Controller (i5 4670, R9 380, 24GB)

The Semi Portable Toastie machine (i7 3612QM (was an i3) intel HD 4000 16GB)'

Bread and Butter Pudding (i7 7700HQ, 1050ti, 16GB)

Pinoutbutter Sandwhich (raspberry pi 3 B)

The Portable Slice of Bread (N270, HAHAHA, 2GB)

Muffinator (C2D E6600, Geforce 8400, 6GB, 8X2TB HDD)

Toastbuster (WIP, should be cool)

loaf and let dough (A printer that doesn't print black ink)

The Cheese Toastie (C2D (of some sort), GTX 760, 3GB, win XP gaming machine)

The Toaster (C2D, intel HD, 4GB, 2X1TB NAS)

Matter of Loaf and death (some old shitty AMD laptop)

windybread (4X E5470, intel HD, 32GB ECC) (use coming soon, maybe)

And more, several more

Link to comment
https://linustechtips.com/topic/810083-serial-control-on-arduinos/
Share on other sites

Link to post
Share on other sites

2 hours ago, ryan27968 said:

Can you post the code you've got already so we can see where you went wrong?

I have used several different methods, both from the internet and from my own creation, but none worked so I can't give sample code as  I have several different ones/I don't know if I saved them all so I might not even still have the code 

The owner of "too many" computers, called

The Lord of all Toasters (1920X 1080ti 32GB)

The Toasted Controller (i5 4670, R9 380, 24GB)

The Semi Portable Toastie machine (i7 3612QM (was an i3) intel HD 4000 16GB)'

Bread and Butter Pudding (i7 7700HQ, 1050ti, 16GB)

Pinoutbutter Sandwhich (raspberry pi 3 B)

The Portable Slice of Bread (N270, HAHAHA, 2GB)

Muffinator (C2D E6600, Geforce 8400, 6GB, 8X2TB HDD)

Toastbuster (WIP, should be cool)

loaf and let dough (A printer that doesn't print black ink)

The Cheese Toastie (C2D (of some sort), GTX 760, 3GB, win XP gaming machine)

The Toaster (C2D, intel HD, 4GB, 2X1TB NAS)

Matter of Loaf and death (some old shitty AMD laptop)

windybread (4X E5470, intel HD, 32GB ECC) (use coming soon, maybe)

And more, several more

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×