Here's our main.c file. This is automatically generated, and you can safely alter it without worrying about the IDE
breaking it.
Put this code into the
for(;;)
if (Button_Pin_Read() == 0)
{
LED_Pin_Write(1);
}
else
{
LED_Pin_Write(0);
}
It's pretty simple: turn the LED on when the button is pressed and off when it's released.
Now, you can upload the code to the processor. The big red arrows in the picture below show three ways of doing
so: a menu item in the "Build" menu, a button on the menu bar, and CTRL-F5 as a hotkey. Make sure that you're
connected to the "Debug" USB port! The "Target" port can only be used for uploading code via a bootloader.
The IDE will automatically save all open, changed files, and initiate a rebuild if necessary. Then, it will find any
attached programmers and automatically connect and program.
Hardware
This is the PSoC, though, right? So, we can skip the code part, entirely!
Delete the code you just added to the main.c file, and let's do it in the schematic instead.
Open up those pin configuration windows again, and this time check the "HW connection" checkboxes. If
you don't do this, you won't be able to connect the pins to one another.
Then, add a piece of wire (the wire tool can be activated by typing "w" or with the toolbar on the left edge of the
schematic) between the little boxes that appeared on those pin symbols, like this:
loop section:
Need help?
Do you have a question about the FreeSoC2 and is the answer not in the manual?
Questions and answers