Changed processor from PIC to Arduino,completely new need help with programming

I am making a heart pulse measurement instrument (or you can say Oximeter) and I designed the project using the PIC, but because of some reasons I wont be able to use the PIC anymore so I switched to Arduino. I am posting the programme I was using for PIC16F628A which was written in C but I don’t know how do I change the program to fit in the Arduino in C++. I have got the Arduino UNO. Its my first project so I need help. The PIC programme is as follows

sbit IR_Tx at RA3_bit;
sbit DD0_Set at RA2_bit;
sbit DD1_Set at RA1_bit;
sbit DD2_Set at RA0_bit;
sbit start at RB7_bit;
unsigned short j, DD0, DD1, DD2, DD3;
unsigned short pulserate, pulsecount;
unsigned int i;

unsigned short mask(unsigned short num) {
 switch (num) {
 case 0 : return 0xC0;
 case 1 : return 0xF9;
 case 2 : return 0xA4;
 case 3 : return 0xB0;
 case 4 : return 0x99;
 case 5 : return 0x92;
 case 6 : return 0x82;
 case 7 : return 0xF8;
 case 8 : return 0x80;
 case 9 : return 0x90;

void delay_debounce(){

void delay_refresh(){

void countpulse(){
 IR_Tx = 1;
 IR_Tx = 0;
 pulsecount = TMR0;
 pulserate = pulsecount*4;

void display(){
 DD0 = pulserate%10;
 DD0 = mask(DD0);
 DD1 = (pulserate/10)%10;
 DD1 = mask(DD1);
 DD2 = pulserate/100;
 DD2 = mask(DD2);
 for (i = 0; i<=180*j; i++) {
 DD0_Set = 0;
 DD1_Set = 1;
 DD2_Set = 1;
 DD0_Set = 1;
 DD1_Set = 0;
 DD2_Set = 1;
 DD0_Set = 1;
 DD1_Set = 1;
 DD2_Set = 0;
 DD2_Set = 1;

void main() {
 CMCON = 0x07;
 TRISA = 0b00110000;
 TRISB = 0b10000000;
 OPTION_REG = 0b00101000;
 pulserate = 0;
 j = 1;
 do {
 j= 3;
 } while(1);

What hardware are you using to detect the heartbeats ?

Well you can use the structure of your programm and rewrite it in in C(++) using arduino syntax. Most of it is really easy to learn (basic funktions at least). Just read one of the tutorial available online.

analogRead() / analogWrite()
digitalRead() / digitalWrite()
delay() (is in ms) and pinMode()

If you learn what these to you should already be able to rewrite most of your program imo.

I am using IR transmitting diode, a photodiode.
The signal conditioning circuit consists of 2 active low pass filters using opamp to boost the reflected light from the finger. The opamp I have used is MCP602 dual opamp for rail to rail output swing . And a 9V battery connected to lm7805 IC to derive a regulated 5v supply. The uC part has a 3digit common anode seven segment dislpay at the output of uC to display the heartrate. In the programme I have added a 15sec delay between each count of heartrate.

@lastSamurai thanks alot, but if possible can you give me the links to the online tutorials or can they be found on this website itself?

Other things that may help are pinout/port descriptions. Find the UNO on this thread. Port D is the only 8 bit wide port available but it includes the UART RX/TX pins so if you want to use it to drive the display then you cannot use the Serial monitor and may need to disconnect these pins to upload a new sketch.

Datatype and function references here . unsigned short looks to be byte (8 bits). int is signed 16 bit number.

Also be aware the MAX current a pin can sink is 40mA and overall current sink of device is 200mA so check your circuit for driving the 7-segment display.

You look to be using a timer to count pulses so if your still going to do it that way then this may be helpful in setting up the timer as a counter. Another approach for the UNO would be to use an interrupt but the hardware interrupt pins also reside on port d.

Rivas post should already help you a lot.

The arduino forums itself already have some tutorials, but you can just google for some too. Also if you open your arduino IDE you will find the examples too. Most of them are really easy and only use basic functions, but if you combine them...

Imo the main thing you have to understand is that the arduino code doesn't use port manipulation (at least not for the "end user") but abstract methodes like digitalWrite() and pin numbers.