Arduino MEGA insted of PIC?

Hey guys!
Probably this question is not posted in a right part of forum.
I want to build DIY Electrocardiograph using Arduino.
Actually I have a circuit

but it uses a PIC microcontroller.
Help me please to change Arduino instead of PIC. I need a programming part, how to programm AnalogtoDigitalConverter and to get a digital signal on output?

how to programm AnalogtoDigitalConverter

Use the statement
variableName = analogRead(0) ; // will read the analogue input pin zero

and to get a digital signal on output?

the to output the logic level in a variable called fred to the digital pin 5 use:-
digitalWrite(5, fred) ;

There are also I2C devices, connect them to A4 & A5 in place of RB7 and RB6.

However, I suspect your main problem is that you don't understand what the PIC is doing either.

Just mapping the pins to a Mega is probably easy, but I suspect there's a lot more to this than you are asking.

Do you have any idea what the current code does?


Rob