This will be a step by step walkthrough of a semi automatic farm I usually build when playing in a new world. This farm can be used for crops like, wheat, carrots and potatoes.
Step 1: Picking Your Location
I like to build these underground, so I end up starting it in a mountainside or as a room down in a mine. When a farm is underground you don't have to deal with mobs destroying your crops and it can be placed anywhere underground.
I start off with a door and a hallway. just make sure there is plenty of room behind the door. This farm is as big as you want it to be so it can get kind of long.
Step 2: Constructing Your Farm
First i like to make a little room inside the hallway, this is a place to store seeds and collected food later on, and its also a place to craft tools, torches, and other items we will be using. I then leave a wall, and dig to the right and left, 3 spaces from the doorway. If any of these instructions seem complicated just slide through the pictures and it will make sense. Then dig forward 6 spaces so you end up with a 7x7 room. It'll be a center line and 2 rows of 3. now we are going to lower the floor on the 2 rows of three except for the first middle block, see images.
Step 3: Preparing Your Farm
Looking back at the door you should have something that looks like image 1, With one hole in the wall and one in the ceiling right above it. We will be placing pistons in the holes in the wall and switches on the blocks touching the doorway. Then we will place a water block in the hole on the ceiling and flip the switch, this will activate the pistons and hold the water back. The water should fall on a block and then flow down over the whole farm and go into the trough. You should have something that looks like the sixth image, and next we're going to dig out one layer of blocks under the outside walls and under the center walkway. Then you will place water under the whole walkway and under the walls. Then fill in the adjacent 15 dirt blocks in between the two. You should have something like image 11 and a trough at the end like image 12.
You can make this farm have many levels to have more crops per harvest. After every 5 blocks of dirt, you must drop one so the water can flow across everything. The water can only spread across 6 blocks, and we want the 6th to fall over the edge of the next level so it can harvest another 15 blocks of food. As long as you make it look like stairs and each step is 5 blocks long and one tall, the water will move across them and fall into the trough you make at the end.
Step 4: Finishing Touches/ Collection System
In each of those troughs we will be placing three hoppers. The outer two must be be facing the center one and the center one will drop items into a chest placed below. To make a hopper face a certain direction hold the sneak or crouch button while aiming at the object you'd like the hopper to deliver items to. So you can place the chest first, then the middle hopper above it, Then hold sneak and place the hopper on each side while aiming at the center hopper. I like to make a room for it and grow more things in and above the room, on this map i am growing pumpkin above and sugarcane in the room. I leave a walkway down the aisle of pumpkins and make a ladder to the below room.
Step 5: Sowing Your Seed
Then you can craft a hoe and plow the dirt. You can plant anything that will be knocked down by water. Carrots, Potatoes, Wheat, etc.
Step 6: Using Your Farm
Once your crops have grown all you need to do is flip the switches by the door and the crops will harvest themselves. You can pick them up in the chest below the hoppers. Then replant the next batch of crops and enjoy what you have grown.