In my project there will be a box with dog food inside, the idea is to show a red light when it is below the indicated level, to signal the replacement. What type of sensor and programming should I use?
I guess most reliable may be weight.
But the easiest way of implementing this project may be with this high precision optical sensor and the powerful image processing device that’s attached to it, called “eye” and “brain” respectively. As added bonus, this “brain” is very good at fuzzy logic (you old enough to remember that?), so the only programming (also known as “training”) would be:
if (you see the bag is almost empty) flip that light switch to the ON position;
Or mount an IR distance sensor inside (ok, will need to make sure it doesn't get damaged and clogged with crumbs). Choose one where the distance suits the size of the box. If the distance returned is less than the width of the box, there's dog food in the way. (Or, the dog has its head in the box....)
This is an example sensor, but there are others with different ranges. The voltage it gives back relates to the distance by the graph shown, so you just do an analogRead() and if the voltage is less than some threshold you will determine from the graph, turn the light on.
But the easiest way of implementing this project may be with this high precision optical sensor and the powerful image processing device that's attached to it, called "eye" and "brain" respectively.
Where's the fun in that? By that argument, half of what hobbyists do would be rejected before we start.
Like this Instructable, for example.
Of course - but in this case it tends to be a human that does the emptying of the bag, and in most practical situations it's that vary human that also needs to be notified of the bag being in need of refill.
Sorry for not having specified, I will do an automatic dog feeder and I need to know the level of feed for replenishment after a certain amount dumped by the machine. I am a student of robotics in my college and I am learning ...
Know how much you put in, know how much you took out, and you know how much is left.
Or put a scale under it. Probably the most absolute way of knowing how much is in it, and how much you actually dispense.
Don't forget part of Robotics is " human" factors , or in this case " dog" factors .
How will the Dog feel
About being fed by a machine ?
Very happy. Its food, its a dog...
[ eventually it may switch allegiance from human to robot, a risk you'll have to take! ]