The striking of a bell needn't differentiate large or small bells except, in your case, for the range used in random(). Consider the use of a class for your bells and instantiating as many objects as you have bells. Then just loop through each as you cycle through loop. (Compiles, tested only a bit...)
//defines
#define NUM_BELLS 11 //# number of bells to control
#define STRIKE_DWELL_TIME 100ul //mS mS solenoid strike time
//enumerate the bell sizes (small or large)
enum BellSizes
{
SMALL_BELL,
LARGE_BELL
};
//define the pins for each bell (use whatever pins you want)
//pins shown assume Mega2560
const byte pinBell_1 = 5;
const byte pinBell_2 = 6;
const byte pinBell_3 = LED_BUILTIN; //debug pin to visualize strike time
const byte pinBell_4 = 31;
const byte pinBell_5 = 32;
const byte pinBell_6 = 33;
const byte pinBell_7 = 34;
const byte pinBell_8 = 35;
const byte pinBell_9 = 36;
const byte pinBell_A = 37;
const byte pinBell_B = 38;
//arrays of pins and types for easier initialization
const byte pinBells[] =
{
pinBell_1, pinBell_2, pinBell_3,
pinBell_4, pinBell_5, pinBell_6,
pinBell_7, pinBell_8, pinBell_9,
pinBell_A, pinBell_B
};
const byte typeBells[] =
{
SMALL_BELL, SMALL_BELL, SMALL_BELL,
SMALL_BELL, SMALL_BELL, SMALL_BELL,
LARGE_BELL, LARGE_BELL, LARGE_BELL,
LARGE_BELL, LARGE_BELL
};
//the Bell class
class Bell
{
private:
enum States
{
ST_WAIT,
ST_STRIKE
};
//
bool _bType;
byte _bPin;
byte _bState;
unsigned long _timeBell;
unsigned long _timeStrike;
unsigned long _timeDelay;
//
unsigned long _tNow;
public:
Bell::Bell()
{
}//Bell
void Bell::begin( bool type, byte pin, unsigned long strikeTime )
{
//initialize the instance
_bType = type;
_bPin = pin;
_timeStrike = strikeTime;
//
_timeBell = millis();
_bState = ST_WAIT;
//
if( _bType == SMALL_BELL )
_timeDelay = random( 3000, 17000 );
else
_timeDelay = random( 2000, 16000 );
pinMode( _bPin, OUTPUT );
}//begin
//state machine for the instance
void Bell::spin( void )
{
//get time
_tNow = millis();
//is it time for a state change?
if( (_tNow - _timeBell) >= _timeDelay )
{
//yes, save this time for next state change
_timeBell = _tNow;
//run current state
switch( _bState )
{
//if waiting, time to strike the bell
case ST_WAIT:
//strike the bell
digitalWrite( _bPin, HIGH );
//set up the bell-strike time delay
_timeDelay = _timeStrike;
//and move to the strike state
_bState = ST_STRIKE;
break;
case ST_STRIKE:
//we're striking now; time to release the striker
digitalWrite( _bPin, LOW );
//set up the time for the next strike event
//random range will depend on bell size
if( _bType == SMALL_BELL )
_timeDelay = random( 3000, 17000 );
else
_timeDelay = random( 2000, 16000 );
//and now go back and wait
_bState = ST_WAIT;
break;
}//switch
}//if
}//Spin
};//class Bell
//declare as many instances as you have bells
Bell
allBells[NUM_BELLS];
void setup( void )
{
//Serial.begin(115200); //debug
//seed the random generator (make sure A5 floats)
randomSeed( analogRead( A5 ) );
//begin all instances; use the arrays we created to simplify this
for( int i=0; i<NUM_BELLS; i++ )
allBells[i].begin( typeBells[i], pinBells[i], STRIKE_DWELL_TIME );
}//setup
void loop( void )
{
static byte
bellnum = 0;
//each pass through loop we'll process another bell's state machine
allBells[bellnum].spin();
//after processing, move to the next bell
bellnum++;
//until all are done, then cycle back to bell zero
if( bellnum == NUM_BELLS )
bellnum = 0;
}//loop