see above is my edited conclusion. There was no need of sending all 255 numbers as I was mapping my AC voltage output of 220 volts to 255 numbers which can be achieved by mapping it to just 170 or 180 whatever we want it to be until our voltage requirement is fulfilled. I set my range to 0-180 as my output reached its maximum at this value.
Please note I used both these codes that both of you provided. I did not changed your codes but i changed my Button range that was sending numbers to arduino.
here are both codes that solved issue one is commented out. Indeed I need to change N and F as they exist between 0-180 numbers . I will choose characters that occur after 180 in ASCII table.
int mydelay = 0;
int myvalue = 0;
int last_CH1_state = 0;
const int PinDiac = 3;
const int PinLed = 11;
enum { LedOn = HIGH, LedOff = LOW };
// -----------------------------------------------------------------------------
void setup ()
{
Serial.begin (9600);
PCICR |= (1 << PCIE0); //enable PCMSK0 scan
PCMSK0 |= (1 << PCINT0); //Set pin D8 trigger an interrupt on state change. Input from optocoupler
pinMode (PinDiac, OUTPUT); //Define D3 as output for the DIAC pulse
pinMode (PinLed, OUTPUT);
digitalWrite (PinDiac, HIGH);
digitalWrite (PinLed, LedOff);
}
// -----------------------------------------------------------------------------
void loop ()
////////////////////////////// SECOND METHOD ///////////////////////////////////
// {
// if (Serial.available()) {
// char rec = Serial.read (); // char is equivalent to byte and uint8_t
// switch (rec) {
// case '\n':
// break;
// case 0:
// digitalWrite (PinLed, LedOff);
// break;
// case 1:
// digitalWrite (PinLed, LedOn);
// break;
// default:
// myvalue = map (rec, 2, 255, 6700, 10);
// Serial.print (" myvalue ");
// Serial.println (myvalue);
// break;
// }
// }
////////////////////// fIRST METHOD \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
{
{
if (Serial.available()) {
char rec = Serial.read ();
switch (rec) {
case '\n':
break;
case 'F':
digitalWrite (PinLed, LedOff);
break;
case 'N':
digitalWrite (PinLed, LedOn);
break;
default:
myvalue = map (rec, 0, 255, 6700, 10);
Serial.print (" myvalue ");
Serial.println (myvalue);
break;
}
}
if (mydelay) {
delayMicroseconds (myvalue); //This delay controls the power
digitalWrite (PinDiac, HIGH);
delayMicroseconds (100);
digitalWrite (PinDiac, LOW);
mydelay=0;
}
}
// -----------------------------------------------------------------------------
ISR (PCINT0_vect) {
bool currentState = PINB & B00000001;
if (currentState != last_CH1_state) {
last_CH1_state = currentState;
if (currentState == HIGH) {
mydelay = 1;
}
}
// If pin 8 is LOW and the last state was HIGH then we have a state change
else if (last_CH1_state == 1) {
mydelay = 1; // We haev detected a state change!
last_CH1_state = 0; //Store the current state into the last state for the next loop
}
}

