جَاءَ أَحْمَدُ - nominative with dammah.
رَأَيْتُ أَحْمَدَ - accusative with fathah.
مَرَرْتُ بِأَحْمَدَ - without ال or idafah, genitive with fathah.
The adjective follows the same basic pattern: هٰذَا ثَوْبٌ أَحْمَرُ / رَأَيْتُ ثَوْبًا أَحْمَرَ / نَظَرْتُ إِلَى ثَوْبٍ أَحْمَرَ.