Why do we need to read the datasheet?
First, what is the meaning of microcontroller?
A microcontroller is a compact integrated circuit designed to govern a specific operation in an embedded system. A typical microcontroller includes a processor, memory and input/output (I/O) peripherals on a single chip. Sometimes referred to as an embedded controller or microcontroller unit (MCU), microcontrollers are found in vehicles, robots, office machines, medical devices, mobile radio transceivers, vending machines and home appliances, among other devices. They are essentially simple miniature personal computers (PCs) designed to control small features of a larger component, without a complex front-end operating system (OS).
For more information go to this site
Arduino Pin 13 ---> SCK
Arduino Pin 12 ---> MISO
Arduino Pin 11 ---> MOSI
Arduino Pin 10 ---> RESET
Arduino 5V ---> VCC
Arduino Ground ---> GND
Code
// constants won't change. They're used here to set pin numbers: const int buttonPin = 8; // the number of the pushbutton pin const int ledPin = 7; // the number of the LED pin // variables will change: int buttonState = 0; // variable for reading the pushbutton status void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); } void loop() { // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); // check if the pushbutton is pressed. If it is, the buttonState is HIGH: if (buttonState == HIGH) { // turn LED on: digitalWrite(ledPin, HIGH); } else { // turn LED off: digitalWrite(ledPin, LOW); } }
Note: I used Button example from Arduino examples,just I have changed the pins number