Thursday, February 3, 2011

Project 10 - Serial Controlled Mood Lamp

Project 10 opened up a lot of questions - all of them related to the code and not the actual electronics. I have to admit that I read over this project about four times, just trying to get my hands around the code. (The pseudo code at the end of the project is very helpful - read it!) But still... there are a LOT of things in this project that are not likely to be familiar to those new to programming. For instance, on page 72, the author refers to a "pointer" - I know what that is (and sort of how it works) but it may be totally new to some readers... (the author does explain it briefly, but it's BRIEF and really more confusing IMO than anything else... but chalk that up to my limited C/C+ and general programming knowledge in general...)

Let's see... what else...

I think there's also an assumption here that the reader will understand that the Serial.available command is not going to start until the Enter button is pressed and sending your RGB values but that's not expressly stated.

There's also no explanation of why the numChar is limited to 15 characters. I'm guessing that spaces are ignored, because in the example "R255, G255, B255" (including the ending NULL), if I count the spaces, I'm getting 17 characters just as the author states... but if it gets cut to 15, that means the last 2 characters get deleted, right? If not the NULL, then at least the '55' at the end of the 'B255' - I may need someone to explain this a bit better.

Page 73 - the author explains the * as designating a pointer, but he states it's been added to the variable name as '*data' - but the code in the book and the code I actually ran has the * added to the char data type - char* - any ideas why? Simply a typo?

The rest of the code, especially parsing the RGB code you type in and having it checked and then routed to the right LED - got it. Not a problem.

Overall, I like the power that Project 10 demonstrates (controlling things via a keyboard) but much of the code is still confusing to me... and I imagine it will be to a lot of readers. I certainly don't have time to dive deep into the C/C+ programming language right now, so I'll just accept that not everything makes sense right now and take what I can and move on...

No comments:

Post a Comment