I am working on a project that uses an OV7670 camera, which sends greyscale pixel data to the arduino, one pixel at a time. To my knowledge, the only data coming in is how dark the pixel should be on the image. Essentially, I need to take the value and detect if it is brighter than a certain threshold, but I can't do that with the format the data is in, which, based on my error messages, I believe is an unsigned char. After some googling, I saw that unsigned chars can be converted into ints by subtracting '0', but this isn't working. Is there some other way to convert an unsigned char to an integer?
unsigned char is already an integer.
Sometimes the integer data that it holds is actually ascii codes. Sometimes it isn't. If what is there is ascii then you can subtract '0' for single digits or use atoi for multi-digit numbers. Sometimes unsigned char is used to hold byte sized pieces of a larger data type like float. If that is the case then you need to reassemble the bytes.
The usual advice is to post your code if you want help with it.
Post the code, using code tags, and the complete error message. Instructions are given in the "How to get the best out of this forum" post, linked at the head of every forum category. Also state which Arduino you are using.
What you want to do is really very simple, once you understand the data format and the programming language basics.
I would post my code, but I actually don't have any access to it right now. I will have access to it again on monday, so I'll post it if this doesn't work. That said, I'll look into the atoi function. I believe the number is a multi-digit, single byte number, because it's supposed to be a number from 0-127. Thanks!
Sorry about that, I probably should have read that post, my bad. I am using an arduino uno. And yeah, I get that what I'm trying to is simple, I'm just new to the unsinged char data type and didn't know why subtracting '0' wasn't working. Thanks for your reply.
I do have to wonder what that sentence might mean. Follow the advice given and enlighten us all.
That makes very little sense. If it should be between 0-127 then I would expect it to be a single byte. If it is more than one byte then it is probably ascii.
Without knowing any details...
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.