Rob Entry (first edit):
R.O.B. is a common sight at most tournaments and he tends to place very high when used by a competent smasher. He is arguably the best camper in the game due to his long range projectile attacks and exceptional down-smash. Furthermore, as the 10th heaviest character with one of the longest recoveries in the game, R.O.B. stays alive for a very long time making his defensive play style even more aggravating to deal with. A few characters can do well when played aggressively against R.O.B. Sadly, Sonic is not one of those characters. In order to expose and capitalize on R.O.B.'s weaknesses Sonic needs to adopt a measured and time-consuming play style.
First of all, even against the short-ranged and weak Sonic, R.O.B. has very little approaching capabilities. His short hop d-air is bad as yours, his short hop b-air is slow and interferes with his momentum, his n-air is too slow to start, and his ground approaches are vulnerable to aerial counter attack. He can spam f-airs quickly if he wants, but like his other aerials, they are easily shielded and punished. Still, that doesn't mean you assume the R.O.B. will only camp. If you can, try to goad the R.O.B. into mounting an offensive. Should this succeed, your aerials and aerial spin charge (ASC) should tear him apart.
Most likely though, R.O.B. will try to camp you out. He will probably be sitting on the stage a good distance from you, but if the stage is smaller he might feel safe only when hogging the ledge where he can hop and spam projectiles from. The latter is more common against characters that cannot tangle with R.O.B. off stage. Sonic, however, can play very aggressively against this sort of camping with relatively little risk to himself. Your biggest friends here are springs and d-airs. Springs will obviously keep you out of harms way, and d-airs, when properly timed, will be extremely difficult for R.O.B. to counter. U-airs are also possible as is stage spiking with your b-air. Your biggest concern once you get close to R.O.B. is his f-air spamming. As long as you make sure these don't push you back out you should be fine.
The more "bread and butter" play-style though is to simply stay on the stage, power up gyros and blast lasers. Although you can shield the lasers easily and catch the gyros with f-air, air-dodging, and pick it up with with your dash attack, you will need to mount an offensive at some point. Running straight into R.O.B. to capitalize on projectile lag may seem like the right thing to do at first, but that will only lead you to a world of problems. First, R.O.B. is very good at dodging and then down-smashing. Simple though it may be, this alone will stop a huge bulk of your attacks on a regular basis. Second, R.O.B.'s close hand game overall can be astonishingly fast. His whiffed grabs are quickly over, his d-tilt is good at shield-locking, and his f-tilt has decent speed and range (though not as good as yours). In fact, one of the only things that Sonic has that consistently beats all of this is his ASC and, to a lesser extent, side-b hop.
The reason these two are so effective is that a majority of R.O.B.'s moves have a blind spot right where his face is. The only way for him to cover this blind spot effectively is to angle a f-smash or short-hop something, which you should be able to spot before you commit to your attack. This is one time where spin canceling will actually be useful for baiting attacks. Of course, the very nature of baiting means that the initial opening is created by the defender, not the attacker. If you cannot get used to this often lengthy process of mind-gaming you will likely lose.
Two general things to note when playing against R.O.B. are that:
1) He is very vulnerable from below. You should be able to juggle him with u-air without much problem. As an added benefit, R.O.B. is slightly more vulnerable to vertical KOs than he is to horizontal KOs. Tie this in with the fact that he is poor at killing people over the top, and you realize that stages with low ceilings are much to your advantage.
2) While R.O.B. tends to use his ridiculously long recovery to simply beast through most characters' edge-guarding, he does not do so well against Sonic. If you account for the homing attack (HA) being able to block off an above stage recovery, you are basically left with a below the stage game that involves you continually pushing out R.O.B. so that he steadily uses up his fuel and eventually cannot up-b anymore. D-air spiking and b-air stage spiking are your friends here. Realize also that if R.O.B. is in his up-b state it takes him a second to be able to attack meaning there will be even greater lag in his aerial defense.