| General > General Technical Chat |
| making a simple IR transmitter |
| << < (5/7) > >> |
| msuffidy:
I just picked up 2 arduinos one was totally sealed so I am hoping one will do it. |
| msuffidy:
I wasn't actually expecting to get this far today, but I potentially got the arduino code part done. It is kind of hard to tell. It is set up to light up the onboard led, which is maybe the same as one of the board headers. But the idea is what I decided to do was make it so I would upload the sample set and then it would execute it at a regular rate specified by the upload. So here is my source and a copy of the test sample. I have not hooked it to the IR led yet. |
| ledtester:
Just a couple of coding tips... In transmit_ir you can simply write: --- Code: ---digitalWrite(LED_BUILTIN, sample_array[array_position]); --- End code --- and this code handles both cases. For bool variables C++ has the predefined constants true and false. You can also use 1 and 0, but it makes it more obvious that you are setting a boolean value. You can also just write if (loadstate) { ... } - there's no need to compare it to a true value. |
| msuffidy:
Yes I guess those are good points. I made an assumption about the code I snipped in that it was waiting for serial to be ok before getting a char. It just skipped over it if it wasn't. Now it seems to work great because I wait for it. Oh I tried TRUE and FALSE and maybe it wanted the lower case ones. |
| msuffidy:
OK I think I fixed all. https://web.ncf.ca/fs864/pickup/sketch_irled1-003.ino |
| Navigation |
| Message Index |
| Next page |
| Previous page |