Last few weeks I have been hunting a bug in Dotty’s code. And sometimes I have the joy of finding a bug after a few hours and solve it. But this one keeps on coming back. And it’s starting to get frustrated. I’m quite sure it isn’t hardware related so it must be the code.
But finally this weekend I found the bug. It was a joyful moment. I nearly gave up, I took apart most of the code starting off fresh. I took me on the right path to find the buggy part. For those interested below is a sample/example of code that went wrong.
for (int i = 0; i <= 10; i++) {
Serial.println(object[i]);
delay(10);
}
Or
for (int i = 0; i < 10; i++) {
Serial.println(object[i]);
delay(10);
}
The first one goes wrong when “object[i]” has a max of nine elements. And on an Arduino this non existing object (10) can give some strange results. Like crashing non related parts of the code.So I found the buggy part and I spend a few hour just to find a “=” to many.
So after finding the buggy part and cheering /celebrating it. I fixed it and started again with rebuilding the code and testing it. This all resulted in a working version one of the code.
So Dotty is up and running again. The new code runs for hours without crashing so I think it’s bug free. I also created a manual where the build function are explained.